| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package com.xpn.xwiki.doc; |
| 21 |
|
|
| 22 |
|
import java.io.ByteArrayInputStream; |
| 23 |
|
import java.io.InputStream; |
| 24 |
|
import java.util.ArrayList; |
| 25 |
|
import java.util.Collections; |
| 26 |
|
import java.util.List; |
| 27 |
|
import java.util.Map; |
| 28 |
|
|
| 29 |
|
import javax.inject.Inject; |
| 30 |
|
import javax.inject.Named; |
| 31 |
|
import javax.inject.Provider; |
| 32 |
|
import javax.inject.Singleton; |
| 33 |
|
|
| 34 |
|
import org.apache.commons.lang3.StringUtils; |
| 35 |
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
| 36 |
|
import org.slf4j.Logger; |
| 37 |
|
import org.xwiki.bridge.DocumentAccessBridge; |
| 38 |
|
import org.xwiki.bridge.DocumentModelBridge; |
| 39 |
|
import org.xwiki.component.annotation.Component; |
| 40 |
|
import org.xwiki.model.EntityType; |
| 41 |
|
import org.xwiki.model.reference.AttachmentReference; |
| 42 |
|
import org.xwiki.model.reference.DocumentReference; |
| 43 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
| 44 |
|
import org.xwiki.model.reference.EntityReference; |
| 45 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
| 46 |
|
import org.xwiki.model.reference.ObjectPropertyReference; |
| 47 |
|
import org.xwiki.model.reference.ObjectReference; |
| 48 |
|
import org.xwiki.security.authorization.ContextualAuthorizationManager; |
| 49 |
|
import org.xwiki.security.authorization.Right; |
| 50 |
|
|
| 51 |
|
import com.xpn.xwiki.XWikiContext; |
| 52 |
|
import com.xpn.xwiki.XWikiException; |
| 53 |
|
import com.xpn.xwiki.objects.BaseObject; |
| 54 |
|
import com.xpn.xwiki.objects.BaseProperty; |
| 55 |
|
import com.xpn.xwiki.objects.classes.PropertyClass; |
| 56 |
|
import com.xpn.xwiki.user.api.XWikiRightService; |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
@version |
| 64 |
|
@since |
| 65 |
|
|
| 66 |
|
@Component |
| 67 |
|
@Singleton |
| |
|
| 34.3% |
Uncovered Elements: 291 (443) |
Complexity: 123 |
Complexity Density: 0.42 |
|
| 68 |
|
public class DefaultDocumentAccessBridge implements DocumentAccessBridge |
| 69 |
|
{ |
| 70 |
|
|
| 71 |
|
@Inject |
| 72 |
|
private Provider<XWikiContext> contextProvider; |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
@Inject |
| 79 |
|
@Named("currentmixed") |
| 80 |
|
private DocumentReferenceResolver<String> currentMixedDocumentReferenceResolver; |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
@Inject |
| 86 |
|
private EntityReferenceSerializer<String> defaultEntityReferenceSerializer; |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
@Inject |
| 93 |
|
@Named("compactwiki") |
| 94 |
|
private EntityReferenceSerializer<String> compactWikiEntityReferenceSerializer; |
| 95 |
|
|
| 96 |
|
@Inject |
| 97 |
|
private Provider<ContextualAuthorizationManager> authorizationProvider; |
| 98 |
|
|
| 99 |
|
@Inject |
| 100 |
|
private Logger logger; |
| 101 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 102 |
3166520 |
private XWikiContext getContext()... |
| 103 |
|
{ |
| 104 |
3166509 |
return this.contextProvider.get(); |
| 105 |
|
} |
| 106 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 107 |
0 |
@Override... |
| 108 |
|
@Deprecated |
| 109 |
|
public DocumentModelBridge getDocument(String documentReference) throws Exception |
| 110 |
|
{ |
| 111 |
0 |
XWikiContext xcontext = getContext(); |
| 112 |
0 |
return xcontext.getWiki().getDocument(documentReference, xcontext).getTranslatedDocument(xcontext); |
| 113 |
|
} |
| 114 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 115 |
13499 |
@Override... |
| 116 |
|
public DocumentModelBridge getDocument(DocumentReference documentReference) throws Exception |
| 117 |
|
{ |
| 118 |
13499 |
XWikiContext xcontext = getContext(); |
| 119 |
13499 |
return xcontext.getWiki().getDocument(documentReference, xcontext).getTranslatedDocument(xcontext); |
| 120 |
|
} |
| 121 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 122 |
225866 |
@Override... |
| 123 |
|
public DocumentReference getCurrentDocumentReference() |
| 124 |
|
{ |
| 125 |
225859 |
XWikiDocument currentDocument = null; |
| 126 |
225836 |
XWikiContext context = getContext(); |
| 127 |
225873 |
if (context != null) { |
| 128 |
225857 |
currentDocument = context.getDoc(); |
| 129 |
|
} |
| 130 |
|
|
| 131 |
225855 |
return currentDocument == null ? null : currentDocument.getDocumentReference(); |
| 132 |
|
} |
| 133 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 134 |
0 |
@Override... |
| 135 |
|
@Deprecated |
| 136 |
|
public String getDocumentContent(String documentReference) throws Exception |
| 137 |
|
{ |
| 138 |
0 |
XWikiContext xcontext = getContext(); |
| 139 |
0 |
return getDocumentContent(documentReference, xcontext.getLanguage()); |
| 140 |
|
} |
| 141 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 142 |
0 |
@Override... |
| 143 |
|
public String getDocumentContentForDefaultLanguage(DocumentReference documentReference) throws Exception |
| 144 |
|
{ |
| 145 |
0 |
XWikiContext xcontext = getContext(); |
| 146 |
0 |
return xcontext.getWiki().getDocument(documentReference, xcontext).getContent(); |
| 147 |
|
} |
| 148 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 149 |
0 |
@Override... |
| 150 |
|
@Deprecated |
| 151 |
|
public String getDocumentContentForDefaultLanguage(String documentReference) throws Exception |
| 152 |
|
{ |
| 153 |
0 |
XWikiContext xcontext = getContext(); |
| 154 |
0 |
return xcontext.getWiki().getDocument(documentReference, xcontext).getContent(); |
| 155 |
|
} |
| 156 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 157 |
0 |
@Override... |
| 158 |
|
public String getDocumentContent(DocumentReference documentReference, String language) throws Exception |
| 159 |
|
{ |
| 160 |
0 |
XWikiContext xcontext = getContext(); |
| 161 |
0 |
String originalRev = (String) xcontext.get("rev"); |
| 162 |
0 |
try { |
| 163 |
0 |
xcontext.remove("rev"); |
| 164 |
0 |
return xcontext.getWiki().getDocument(documentReference, xcontext).getTranslatedContent(language, xcontext); |
| 165 |
|
} finally { |
| 166 |
0 |
if (originalRev != null) { |
| 167 |
0 |
xcontext.put("rev", originalRev); |
| 168 |
|
} |
| 169 |
|
} |
| 170 |
|
} |
| 171 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 172 |
0 |
@Override... |
| 173 |
|
@Deprecated |
| 174 |
|
public String getDocumentContent(String documentReference, String language) throws Exception |
| 175 |
|
{ |
| 176 |
0 |
XWikiContext xcontext = getContext(); |
| 177 |
0 |
String originalRev = (String) xcontext.get("rev"); |
| 178 |
0 |
try { |
| 179 |
0 |
xcontext.remove("rev"); |
| 180 |
0 |
return xcontext.getWiki().getDocument(documentReference, xcontext).getTranslatedContent(language, xcontext); |
| 181 |
|
} finally { |
| 182 |
0 |
if (originalRev != null) { |
| 183 |
0 |
xcontext.put("rev", originalRev); |
| 184 |
|
} |
| 185 |
|
} |
| 186 |
|
} |
| 187 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 188 |
3666 |
@Override... |
| 189 |
|
public boolean exists(DocumentReference documentReference) |
| 190 |
|
{ |
| 191 |
3666 |
XWikiContext context = getContext(); |
| 192 |
3668 |
if (context != null) { |
| 193 |
3668 |
return context.getWiki().exists(documentReference, context); |
| 194 |
|
} else { |
| 195 |
0 |
return false; |
| 196 |
|
} |
| 197 |
|
} |
| 198 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 199 |
0 |
@Override... |
| 200 |
|
@Deprecated |
| 201 |
|
public boolean exists(String documentReference) |
| 202 |
|
{ |
| 203 |
0 |
XWikiContext context = getContext(); |
| 204 |
0 |
if (context != null) { |
| 205 |
0 |
return context.getWiki().exists(documentReference, context); |
| 206 |
|
} else { |
| 207 |
0 |
return false; |
| 208 |
|
} |
| 209 |
|
} |
| 210 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 211 |
0 |
@Override... |
| 212 |
|
public void setDocumentContent(DocumentReference documentReference, String content, String editComment, |
| 213 |
|
boolean isMinorEdit) throws Exception |
| 214 |
|
{ |
| 215 |
0 |
XWikiContext xcontext = getContext(); |
| 216 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 217 |
0 |
doc.setContent(content); |
| 218 |
0 |
saveDocument(doc, editComment, isMinorEdit); |
| 219 |
|
} |
| 220 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 221 |
0 |
@Override... |
| 222 |
|
@Deprecated |
| 223 |
|
public void setDocumentContent(String documentReference, String content, String editComment, boolean isMinorEdit) |
| 224 |
|
throws Exception |
| 225 |
|
{ |
| 226 |
0 |
XWikiContext xcontext = getContext(); |
| 227 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 228 |
0 |
doc.setContent(content); |
| 229 |
0 |
saveDocument(doc, editComment, isMinorEdit); |
| 230 |
|
} |
| 231 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 232 |
0 |
@Override... |
| 233 |
|
@Deprecated |
| 234 |
|
public String getDocumentSyntaxId(String documentReference) throws Exception |
| 235 |
|
{ |
| 236 |
0 |
XWikiContext xcontext = getContext(); |
| 237 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 238 |
|
|
| 239 |
0 |
return doc.getSyntaxId(); |
| 240 |
|
} |
| 241 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 242 |
0 |
@Override... |
| 243 |
|
public void setDocumentSyntaxId(DocumentReference documentReference, String syntaxId) throws Exception |
| 244 |
|
{ |
| 245 |
0 |
XWikiContext xcontext = getContext(); |
| 246 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 247 |
0 |
doc.setSyntaxId(syntaxId); |
| 248 |
0 |
saveDocument(doc, String.format("Changed document syntax from [%s] to [%s].", doc.getSyntax(), syntaxId), true); |
| 249 |
|
} |
| 250 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 251 |
0 |
@Override... |
| 252 |
|
@Deprecated |
| 253 |
|
public void setDocumentSyntaxId(String documentReference, String syntaxId) throws Exception |
| 254 |
|
{ |
| 255 |
0 |
XWikiContext xcontext = getContext(); |
| 256 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 257 |
0 |
String oldSyntaxId = doc.getSyntaxId(); |
| 258 |
0 |
doc.setSyntaxId(syntaxId); |
| 259 |
0 |
saveDocument(doc, String.format("Changed document syntax from [%s] to [%s].", oldSyntaxId, syntaxId), true); |
| 260 |
|
} |
| 261 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 262 |
0 |
@Override... |
| 263 |
|
public void setDocumentParentReference(DocumentReference documentReference, DocumentReference parentReference) |
| 264 |
|
throws Exception |
| 265 |
|
{ |
| 266 |
0 |
XWikiContext xcontext = getContext(); |
| 267 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 268 |
0 |
doc.setParent(this.compactWikiEntityReferenceSerializer.serialize(parentReference, doc.getDocumentReference())); |
| 269 |
0 |
saveDocument( |
| 270 |
|
doc, |
| 271 |
|
String.format("Changed document parent to [%s].", |
| 272 |
|
this.defaultEntityReferenceSerializer.serialize(parentReference)), true); |
| 273 |
|
} |
| 274 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 275 |
0 |
@Override... |
| 276 |
|
public void setDocumentTitle(DocumentReference documentReference, String title) throws Exception |
| 277 |
|
{ |
| 278 |
0 |
XWikiContext xcontext = getContext(); |
| 279 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 280 |
0 |
doc.setTitle(title); |
| 281 |
0 |
saveDocument(doc, String.format("Changed document title to [%s].", title), true); |
| 282 |
|
} |
| 283 |
|
|
| |
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 284 |
18 |
@Override... |
| 285 |
|
public int getObjectNumber(DocumentReference documentReference, DocumentReference classReference, |
| 286 |
|
String propertyName, String valueToMatch) |
| 287 |
|
{ |
| 288 |
18 |
try { |
| 289 |
18 |
XWikiContext xcontext = getContext(); |
| 290 |
18 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 291 |
18 |
BaseObject object = doc.getXObject(classReference, propertyName, valueToMatch, false); |
| 292 |
18 |
return object != null ? object.getNumber() : -1; |
| 293 |
|
} catch (XWikiException e) { |
| 294 |
0 |
return -1; |
| 295 |
|
} |
| 296 |
|
} |
| 297 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 298 |
1 |
@Override... |
| 299 |
|
public Object getProperty(ObjectPropertyReference objectPropertyReference) |
| 300 |
|
{ |
| 301 |
1 |
ObjectReference objectReference = (ObjectReference) objectPropertyReference.extractReference(EntityType.OBJECT); |
| 302 |
|
|
| 303 |
1 |
return getProperty(objectReference, objectPropertyReference.getName()); |
| 304 |
|
} |
| 305 |
|
|
| |
|
| 78.9% |
Uncovered Elements: 4 (19) |
Complexity: 6 |
Complexity Density: 0.46 |
|
| 306 |
1 |
@Override... |
| 307 |
|
public Object getProperty(ObjectReference objectReference, String propertyName) |
| 308 |
|
{ |
| 309 |
1 |
Object value = null; |
| 310 |
|
|
| 311 |
1 |
try { |
| 312 |
1 |
XWikiContext xcontext = getContext(); |
| 313 |
|
|
| 314 |
1 |
if (xcontext != null && xcontext.getWiki() != null) { |
| 315 |
1 |
DocumentReference documentReference = |
| 316 |
|
(DocumentReference) objectReference.extractReference(EntityType.DOCUMENT); |
| 317 |
1 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 318 |
1 |
BaseObject object = doc.getXObject(objectReference); |
| 319 |
1 |
if (object != null) { |
| 320 |
1 |
BaseProperty property = (BaseProperty) object.get(propertyName); |
| 321 |
1 |
if (property != null) { |
| 322 |
1 |
value = property.getValue(); |
| 323 |
|
} |
| 324 |
|
} |
| 325 |
|
} |
| 326 |
|
} catch (Exception e) { |
| 327 |
0 |
this.logger.error("Failed to get property", e); |
| 328 |
|
} |
| 329 |
|
|
| 330 |
1 |
return value; |
| 331 |
|
} |
| 332 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.5 |
|
| 333 |
0 |
@Override... |
| 334 |
|
public Object getProperty(String documentReference, String className, int objectNumber, String propertyName) |
| 335 |
|
{ |
| 336 |
0 |
Object value = null; |
| 337 |
|
|
| 338 |
0 |
try { |
| 339 |
0 |
XWikiContext xcontext = getContext(); |
| 340 |
|
|
| 341 |
0 |
if (xcontext != null && xcontext.getWiki() != null) { |
| 342 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 343 |
0 |
BaseObject object = doc.getObject(className, objectNumber); |
| 344 |
0 |
if (object != null) { |
| 345 |
0 |
BaseProperty property = (BaseProperty) object.get(propertyName); |
| 346 |
0 |
if (property != null) { |
| 347 |
0 |
value = property.getValue(); |
| 348 |
|
} |
| 349 |
|
} |
| 350 |
|
} |
| 351 |
|
} catch (Exception e) { |
| 352 |
0 |
this.logger.error("Failed to get property", e); |
| 353 |
|
} |
| 354 |
|
|
| 355 |
0 |
return value; |
| 356 |
|
} |
| 357 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.5 |
|
| 358 |
0 |
@Override... |
| 359 |
|
@Deprecated |
| 360 |
|
public Object getProperty(String documentReference, String className, String propertyName) |
| 361 |
|
{ |
| 362 |
0 |
Object value = null; |
| 363 |
|
|
| 364 |
0 |
try { |
| 365 |
0 |
XWikiContext xcontext = getContext(); |
| 366 |
|
|
| 367 |
0 |
if (xcontext != null && xcontext.getWiki() != null) { |
| 368 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 369 |
0 |
BaseObject object = doc.getObject(className); |
| 370 |
0 |
if (object != null) { |
| 371 |
0 |
BaseProperty property = (BaseProperty) object.get(propertyName); |
| 372 |
0 |
if (property != null) { |
| 373 |
0 |
value = property.getValue(); |
| 374 |
|
} |
| 375 |
|
} |
| 376 |
|
} |
| 377 |
|
} catch (Exception e) { |
| 378 |
0 |
this.logger.error("Failed to get property", e); |
| 379 |
|
} |
| 380 |
|
|
| 381 |
0 |
return value; |
| 382 |
|
} |
| 383 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 2 (18) |
Complexity: 6 |
Complexity Density: 0.5 |
|
| 384 |
2651 |
@Override... |
| 385 |
|
public Object getProperty(DocumentReference documentReference, DocumentReference classReference, String propertyName) |
| 386 |
|
{ |
| 387 |
2651 |
Object value = null; |
| 388 |
|
|
| 389 |
2651 |
try { |
| 390 |
2651 |
XWikiContext xcontext = getContext(); |
| 391 |
|
|
| 392 |
2651 |
if (xcontext != null && xcontext.getWiki() != null) { |
| 393 |
2651 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 394 |
2651 |
BaseObject object = doc.getXObject(classReference); |
| 395 |
2651 |
if (object != null) { |
| 396 |
612 |
BaseProperty property = (BaseProperty) object.get(propertyName); |
| 397 |
612 |
if (property != null) { |
| 398 |
586 |
value = property.getValue(); |
| 399 |
|
} |
| 400 |
|
} |
| 401 |
|
} |
| 402 |
|
} catch (Exception e) { |
| 403 |
0 |
this.logger.error("Failed to get property", e); |
| 404 |
|
} |
| 405 |
|
|
| 406 |
2651 |
return value; |
| 407 |
|
} |
| 408 |
|
|
| |
|
| 77.8% |
Uncovered Elements: 4 (18) |
Complexity: 6 |
Complexity Density: 0.5 |
|
| 409 |
18 |
@Override... |
| 410 |
|
public Object getProperty(DocumentReference documentReference, DocumentReference classReference, int objectNumber, |
| 411 |
|
String propertyName) |
| 412 |
|
{ |
| 413 |
18 |
Object value = null; |
| 414 |
|
|
| 415 |
18 |
try { |
| 416 |
18 |
XWikiContext xcontext = getContext(); |
| 417 |
|
|
| 418 |
18 |
if (xcontext != null && xcontext.getWiki() != null) { |
| 419 |
18 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 420 |
18 |
BaseObject object = doc.getXObject(classReference, objectNumber); |
| 421 |
18 |
if (object != null) { |
| 422 |
18 |
BaseProperty property = (BaseProperty) object.get(propertyName); |
| 423 |
18 |
if (property != null) { |
| 424 |
18 |
value = property.getValue(); |
| 425 |
|
} |
| 426 |
|
} |
| 427 |
|
} |
| 428 |
|
} catch (Exception e) { |
| 429 |
0 |
this.logger.error("Failed to get property", e); |
| 430 |
|
} |
| 431 |
|
|
| 432 |
18 |
return value; |
| 433 |
|
} |
| 434 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.5 |
|
| 435 |
0 |
@Override... |
| 436 |
|
public Object getProperty(String documentReference, String propertyName) |
| 437 |
|
{ |
| 438 |
0 |
Object value = null; |
| 439 |
|
|
| 440 |
0 |
try { |
| 441 |
0 |
XWikiContext xcontext = getContext(); |
| 442 |
|
|
| 443 |
0 |
if (xcontext != null && xcontext.getWiki() != null) { |
| 444 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 445 |
0 |
BaseObject object = doc.getFirstObject(propertyName, xcontext); |
| 446 |
0 |
if (object != null) { |
| 447 |
0 |
BaseProperty property = (BaseProperty) object.get(propertyName); |
| 448 |
0 |
if (property != null) { |
| 449 |
0 |
value = property.getValue(); |
| 450 |
|
} |
| 451 |
|
} |
| 452 |
|
} |
| 453 |
|
} catch (Exception e) { |
| 454 |
0 |
this.logger.error("Failed to get property", e); |
| 455 |
|
} |
| 456 |
|
|
| 457 |
0 |
return value; |
| 458 |
|
} |
| 459 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 460 |
0 |
@Override... |
| 461 |
|
public List<Object> getProperties(String documentReference, String className) |
| 462 |
|
{ |
| 463 |
0 |
List<Object> result; |
| 464 |
0 |
try { |
| 465 |
0 |
XWikiContext xcontext = getContext(); |
| 466 |
0 |
result = |
| 467 |
|
new ArrayList<Object>(xcontext.getWiki().getDocument(documentReference, xcontext).getObject(className) |
| 468 |
|
.getFieldList()); |
| 469 |
|
} catch (Exception ex) { |
| 470 |
0 |
result = Collections.emptyList(); |
| 471 |
|
} |
| 472 |
0 |
return result; |
| 473 |
|
} |
| 474 |
|
|
| |
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 475 |
228 |
@Override... |
| 476 |
|
public String getPropertyType(String className, String propertyName) throws Exception |
| 477 |
|
{ |
| 478 |
228 |
XWikiContext xcontext = getContext(); |
| 479 |
228 |
PropertyClass pc = null; |
| 480 |
228 |
try { |
| 481 |
228 |
pc = (PropertyClass) xcontext.getWiki().getDocument(className, xcontext).getXClass().get(propertyName); |
| 482 |
|
} catch (XWikiException e) { |
| 483 |
0 |
this.logger.warn("Failed to get document [{}]. Root cause: [{}]", className, |
| 484 |
|
ExceptionUtils.getRootCauseMessage(e)); |
| 485 |
|
} |
| 486 |
|
|
| 487 |
228 |
return pc == null ? null : pc.newProperty().getClass().getName(); |
| 488 |
|
} |
| 489 |
|
|
| |
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 490 |
252 |
@Override... |
| 491 |
|
public boolean isPropertyCustomMapped(String className, String property) throws Exception |
| 492 |
|
{ |
| 493 |
252 |
XWikiContext xcontext = getContext(); |
| 494 |
252 |
if (!xcontext.getWiki().hasCustomMappings()) { |
| 495 |
0 |
return false; |
| 496 |
|
} |
| 497 |
252 |
List<String> lst = xcontext.getWiki().getClass(className, xcontext).getCustomMappingPropertyList(xcontext); |
| 498 |
252 |
return lst != null && lst.contains(property); |
| 499 |
|
} |
| 500 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 501 |
0 |
@Override... |
| 502 |
|
@Deprecated |
| 503 |
|
public void setProperty(String documentReference, String className, String propertyName, Object propertyValue) |
| 504 |
|
throws Exception |
| 505 |
|
{ |
| 506 |
0 |
XWikiContext xcontext = getContext(); |
| 507 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 508 |
0 |
BaseObject obj = doc.getObject(className, true, xcontext); |
| 509 |
0 |
if (obj != null) { |
| 510 |
0 |
obj.set(propertyName, propertyValue, xcontext); |
| 511 |
0 |
saveDocument(doc, String.format("Property [%s] set.", propertyName), true); |
| 512 |
|
} |
| 513 |
|
} |
| 514 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 515 |
0 |
@Override... |
| 516 |
|
public void setProperty(DocumentReference documentReference, DocumentReference classReference, String propertyName, |
| 517 |
|
Object propertyValue) throws Exception |
| 518 |
|
{ |
| 519 |
0 |
XWikiContext xcontext = getContext(); |
| 520 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 521 |
0 |
BaseObject obj = doc.getXObject(classReference, true, xcontext); |
| 522 |
0 |
if (obj != null) { |
| 523 |
0 |
obj.set(propertyName, propertyValue, xcontext); |
| 524 |
0 |
saveDocument(doc, String.format("Property [%s] set.", propertyName), true); |
| 525 |
|
} |
| 526 |
|
} |
| 527 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 528 |
0 |
@Override... |
| 529 |
|
@Deprecated |
| 530 |
|
public byte[] getAttachmentContent(String documentReference, String attachmentFilename) throws Exception |
| 531 |
|
{ |
| 532 |
0 |
XWikiContext xcontext = getContext(); |
| 533 |
0 |
return xcontext.getWiki().getDocument(documentReference, xcontext).getAttachment(attachmentFilename) |
| 534 |
|
.getContent(xcontext); |
| 535 |
|
} |
| 536 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 537 |
0 |
@Override... |
| 538 |
|
public InputStream getAttachmentContent(AttachmentReference attachmentReference) throws Exception |
| 539 |
|
{ |
| 540 |
0 |
XWikiContext xcontext = getContext(); |
| 541 |
0 |
XWikiDocument attachmentDocument = |
| 542 |
|
xcontext.getWiki().getDocument(attachmentReference.getDocumentReference(), xcontext); |
| 543 |
0 |
return new ByteArrayInputStream(attachmentDocument.getAttachment(attachmentReference.getName()).getContent( |
| 544 |
|
xcontext)); |
| 545 |
|
} |
| 546 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 3 |
Complexity Density: 0.19 |
|
| 547 |
0 |
@Override... |
| 548 |
|
public void setAttachmentContent(AttachmentReference attachmentReference, byte[] attachmentData) throws Exception |
| 549 |
|
{ |
| 550 |
0 |
XWikiContext xcontext = getContext(); |
| 551 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(attachmentReference.getDocumentReference(), xcontext); |
| 552 |
0 |
XWikiAttachment attachment = doc.getAttachment(attachmentReference.getName()); |
| 553 |
0 |
if (attachment == null) { |
| 554 |
0 |
attachment = new XWikiAttachment(); |
| 555 |
0 |
doc.getAttachmentList().add(attachment); |
| 556 |
0 |
doc.setComment("Add new attachment " + attachmentReference.getName()); |
| 557 |
|
} else { |
| 558 |
0 |
doc.setComment("Update attachment " + attachmentReference.getName()); |
| 559 |
|
} |
| 560 |
0 |
attachment.setContent(attachmentData); |
| 561 |
0 |
attachment.setFilename(attachmentReference.getName()); |
| 562 |
0 |
attachment.setAuthor(getCurrentUser()); |
| 563 |
0 |
attachment.setDoc(doc); |
| 564 |
0 |
doc.setAuthorReference(getContext().getUserReference()); |
| 565 |
0 |
if (doc.isNew()) { |
| 566 |
0 |
doc.setCreatorReference(getContext().getUserReference()); |
| 567 |
|
} |
| 568 |
0 |
doc.saveAttachmentContent(attachment, xcontext); |
| 569 |
|
} |
| 570 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 3 |
Complexity Density: 0.19 |
|
| 571 |
0 |
@Override... |
| 572 |
|
@Deprecated |
| 573 |
|
public void setAttachmentContent(String documentReference, String attachmentFilename, byte[] attachmentData) |
| 574 |
|
throws Exception |
| 575 |
|
{ |
| 576 |
0 |
XWikiContext xcontext = getContext(); |
| 577 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); |
| 578 |
0 |
XWikiAttachment attachment = doc.getAttachment(attachmentFilename); |
| 579 |
0 |
if (attachment == null) { |
| 580 |
0 |
attachment = new XWikiAttachment(); |
| 581 |
0 |
doc.getAttachmentList().add(attachment); |
| 582 |
0 |
doc.setComment("Add new attachment " + attachmentFilename); |
| 583 |
|
} else { |
| 584 |
0 |
doc.setComment("Update attachment " + attachmentFilename); |
| 585 |
|
} |
| 586 |
0 |
attachment.setContent(attachmentData); |
| 587 |
0 |
attachment.setFilename(attachmentFilename); |
| 588 |
0 |
attachment.setAuthor(getCurrentUser()); |
| 589 |
0 |
attachment.setDoc(doc); |
| 590 |
0 |
doc.setAuthor(getCurrentUser()); |
| 591 |
0 |
if (doc.isNew()) { |
| 592 |
0 |
doc.setCreator(getCurrentUser()); |
| 593 |
|
} |
| 594 |
0 |
doc.saveAttachmentContent(attachment, xcontext); |
| 595 |
|
} |
| 596 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 597 |
0 |
@Override... |
| 598 |
|
public List<AttachmentReference> getAttachmentReferences(DocumentReference documentReference) throws Exception |
| 599 |
|
{ |
| 600 |
0 |
XWikiContext xcontext = getContext(); |
| 601 |
0 |
List<XWikiAttachment> attachments = |
| 602 |
|
xcontext.getWiki().getDocument(documentReference, xcontext).getAttachmentList(); |
| 603 |
|
|
| 604 |
0 |
List<AttachmentReference> attachmentReferences = new ArrayList<AttachmentReference>(attachments.size()); |
| 605 |
0 |
for (XWikiAttachment attachment : attachments) { |
| 606 |
0 |
attachmentReferences.add(attachment.getReference()); |
| 607 |
|
} |
| 608 |
|
|
| 609 |
0 |
return attachmentReferences; |
| 610 |
|
} |
| 611 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 612 |
0 |
@Override... |
| 613 |
|
public String getAttachmentVersion(AttachmentReference attachmentReference) throws Exception |
| 614 |
|
{ |
| 615 |
0 |
XWikiContext xcontext = getContext(); |
| 616 |
0 |
XWikiDocument doc = xcontext.getWiki().getDocument(attachmentReference.getDocumentReference(), xcontext); |
| 617 |
0 |
XWikiAttachment attachment = doc.getAttachment(attachmentReference.getName()); |
| 618 |
0 |
return attachment == null ? null : attachment.getVersion(); |
| 619 |
|
} |
| 620 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 621 |
266 |
@Override... |
| 622 |
|
public String getDocumentURL(DocumentReference documentReference, String action, String queryString, String anchor) |
| 623 |
|
{ |
| 624 |
266 |
return getDocumentURL(documentReference, action, queryString, anchor, false); |
| 625 |
|
} |
| 626 |
|
|
| |
|
| 55.6% |
Uncovered Elements: 4 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 627 |
266 |
@Override... |
| 628 |
|
public String getDocumentURL(final DocumentReference documentReference, final String action, |
| 629 |
|
final String queryString, final String anchor, final boolean isFullURL) |
| 630 |
|
{ |
| 631 |
266 |
if (documentReference == null) { |
| 632 |
0 |
return this.getDocumentURL(this.getContext().getDoc().getDocumentReference(), action, queryString, anchor, |
| 633 |
|
isFullURL); |
| 634 |
|
} |
| 635 |
266 |
if (isFullURL) { |
| 636 |
0 |
return this.getContext().getURLFactory().createExternalURL(extractSpacesFromDocumentReference( |
| 637 |
|
documentReference), documentReference.getName(), action, queryString, anchor, |
| 638 |
|
documentReference.getWikiReference().getName(), this.getContext()).toString(); |
| 639 |
|
} else { |
| 640 |
266 |
return this.getContext().getWiki() |
| 641 |
|
.getURL(documentReference, action, queryString, anchor, this.getContext()); |
| 642 |
|
} |
| 643 |
|
} |
| 644 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 645 |
2 |
@Override... |
| 646 |
|
@Deprecated |
| 647 |
|
public String getURL(String documentReference, String action, String queryString, String anchor) |
| 648 |
|
{ |
| 649 |
2 |
XWikiContext xcontext = getContext(); |
| 650 |
|
|
| 651 |
|
|
| 652 |
2 |
String computedDocumentName = documentReference; |
| 653 |
2 |
if (StringUtils.isEmpty(documentReference)) { |
| 654 |
2 |
computedDocumentName = xcontext.getDoc().getFullName(); |
| 655 |
|
} |
| 656 |
|
|
| 657 |
2 |
return xcontext.getWiki().getURL(computedDocumentName, action, queryString, anchor, xcontext); |
| 658 |
|
} |
| 659 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 660 |
0 |
@Override... |
| 661 |
|
@Deprecated |
| 662 |
|
public String getAttachmentURL(String documentReference, String attachmentName) |
| 663 |
|
{ |
| 664 |
0 |
XWikiContext xcontext = getContext(); |
| 665 |
0 |
String attachmentURL; |
| 666 |
0 |
try { |
| 667 |
0 |
attachmentURL = |
| 668 |
|
xcontext.getWiki().getAttachmentURL( |
| 669 |
0 |
documentReference == null ? xcontext.getDoc().getFullName() : documentReference, attachmentName, |
| 670 |
|
xcontext); |
| 671 |
|
} catch (XWikiException e) { |
| 672 |
|
|
| 673 |
|
|
| 674 |
0 |
throw new RuntimeException("Failed to get attachment URL", e); |
| 675 |
|
} |
| 676 |
0 |
return attachmentURL; |
| 677 |
|
} |
| 678 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 679 |
0 |
@Override... |
| 680 |
|
public String getAttachmentURL(AttachmentReference attachmentReference, boolean isFullURL) |
| 681 |
|
{ |
| 682 |
0 |
return getAttachmentURL(attachmentReference, null, isFullURL); |
| 683 |
|
} |
| 684 |
|
|
| |
|
| 64.7% |
Uncovered Elements: 6 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
| 685 |
276 |
@Override... |
| 686 |
|
public String getAttachmentURL(AttachmentReference attachmentReference, String queryString, boolean isFullURL) |
| 687 |
|
{ |
| 688 |
276 |
String url; |
| 689 |
276 |
if (isFullURL) { |
| 690 |
0 |
XWikiContext xcontext = getContext(); |
| 691 |
0 |
url = xcontext.getURLFactory().createAttachmentURL(attachmentReference.getName(), |
| 692 |
|
extractSpacesFromDocumentReference(attachmentReference.getDocumentReference()), |
| 693 |
|
attachmentReference.getDocumentReference().getName(), "download", queryString, |
| 694 |
|
attachmentReference.getDocumentReference().getWikiReference().getName(), xcontext).toString(); |
| 695 |
|
} else { |
| 696 |
276 |
XWikiContext xcontext = getContext(); |
| 697 |
276 |
String documentReference = |
| 698 |
|
this.defaultEntityReferenceSerializer.serialize(attachmentReference.getDocumentReference()); |
| 699 |
276 |
if (documentReference == null) { |
| 700 |
0 |
documentReference = xcontext.getDoc().getFullName(); |
| 701 |
|
} |
| 702 |
276 |
String fileName = attachmentReference.getName(); |
| 703 |
276 |
try { |
| 704 |
276 |
url = xcontext.getWiki().getAttachmentURL(documentReference, fileName, queryString, xcontext); |
| 705 |
|
} catch (XWikiException e) { |
| 706 |
|
|
| 707 |
|
|
| 708 |
0 |
throw new RuntimeException("Failed to get attachment URL", e); |
| 709 |
|
} |
| 710 |
|
} |
| 711 |
276 |
return url; |
| 712 |
|
} |
| 713 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 714 |
0 |
@Override... |
| 715 |
|
@Deprecated |
| 716 |
|
public List<String> getAttachmentURLs(DocumentReference documentReference, boolean isFullURL) throws Exception |
| 717 |
|
{ |
| 718 |
0 |
List<String> urls = new ArrayList<String>(); |
| 719 |
0 |
for (AttachmentReference attachmentReference : getAttachmentReferences(documentReference)) { |
| 720 |
0 |
urls.add(getAttachmentURL(attachmentReference, isFullURL)); |
| 721 |
|
} |
| 722 |
0 |
return urls; |
| 723 |
|
} |
| 724 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 725 |
2992 |
@Override... |
| 726 |
|
public boolean isDocumentViewable(DocumentReference documentReference) |
| 727 |
|
{ |
| 728 |
2992 |
return hasRight(documentReference, "view"); |
| 729 |
|
} |
| 730 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 731 |
0 |
@Override... |
| 732 |
|
@Deprecated |
| 733 |
|
public boolean isDocumentViewable(String documentReference) |
| 734 |
|
{ |
| 735 |
0 |
return hasRight(documentReference, "view"); |
| 736 |
|
} |
| 737 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 738 |
0 |
@Override... |
| 739 |
|
@Deprecated |
| 740 |
|
public boolean isDocumentEditable(String documentReference) |
| 741 |
|
{ |
| 742 |
0 |
return hasRight(documentReference, "edit"); |
| 743 |
|
} |
| 744 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 745 |
0 |
@Override... |
| 746 |
|
public boolean isDocumentEditable(DocumentReference documentReference) |
| 747 |
|
{ |
| 748 |
0 |
return hasRight(documentReference, "edit"); |
| 749 |
|
} |
| 750 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 751 |
90 |
@Override... |
| 752 |
|
public boolean hasProgrammingRights() |
| 753 |
|
{ |
| 754 |
90 |
return this.authorizationProvider.get().hasAccess(Right.PROGRAM); |
| 755 |
|
} |
| 756 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 757 |
247 |
@Override... |
| 758 |
|
@Deprecated |
| 759 |
|
public String getCurrentUser() |
| 760 |
|
{ |
| 761 |
247 |
DocumentReference userReference = getContext().getUserReference(); |
| 762 |
|
|
| 763 |
|
|
| 764 |
247 |
if (userReference != null) { |
| 765 |
54 |
return this.defaultEntityReferenceSerializer.serialize(userReference); |
| 766 |
|
} else { |
| 767 |
193 |
return XWikiRightService.GUEST_USER_FULLNAME; |
| 768 |
|
} |
| 769 |
|
} |
| 770 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 771 |
2891787 |
@Override... |
| 772 |
|
public DocumentReference getCurrentUserReference() |
| 773 |
|
{ |
| 774 |
2891782 |
XWikiContext xcontext = getContext(); |
| 775 |
2891893 |
return xcontext != null ? xcontext.getUserReference() : null; |
| 776 |
|
} |
| 777 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 778 |
1126 |
@Override... |
| 779 |
|
public void setCurrentUser(String userName) |
| 780 |
|
{ |
| 781 |
1126 |
getContext().setUser(userName); |
| 782 |
|
} |
| 783 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 784 |
0 |
@Override... |
| 785 |
|
public String getDefaultEncoding() |
| 786 |
|
{ |
| 787 |
0 |
return getContext().getWiki().getEncoding(); |
| 788 |
|
} |
| 789 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 790 |
15043 |
@Override... |
| 791 |
|
public void popDocumentFromContext(Map<String, Object> backupObjects) |
| 792 |
|
{ |
| 793 |
15041 |
XWikiDocument.restoreContext(backupObjects, getContext()); |
| 794 |
|
} |
| 795 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 796 |
0 |
@Override... |
| 797 |
|
@Deprecated |
| 798 |
|
public void pushDocumentInContext(Map<String, Object> backupObjects, String documentReference) throws Exception |
| 799 |
|
{ |
| 800 |
0 |
XWikiContext xcontext = getContext(); |
| 801 |
|
|
| 802 |
|
|
| 803 |
0 |
XWikiDocument.backupContext(backupObjects, xcontext); |
| 804 |
|
|
| 805 |
|
|
| 806 |
0 |
xcontext = getContext(); |
| 807 |
|
|
| 808 |
|
|
| 809 |
0 |
xcontext.getWiki().getDocument(documentReference, xcontext).setAsContextDoc(xcontext); |
| 810 |
|
} |
| 811 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 812 |
4160 |
@Override... |
| 813 |
|
public void pushDocumentInContext(Map<String, Object> backupObjects, DocumentReference documentReference) |
| 814 |
|
throws Exception |
| 815 |
|
{ |
| 816 |
4160 |
pushDocumentInContext(backupObjects, getDocument(documentReference)); |
| 817 |
|
} |
| 818 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 819 |
4170 |
@Override... |
| 820 |
|
public void pushDocumentInContext(Map<String, Object> backupObjects, DocumentModelBridge document) throws Exception |
| 821 |
|
{ |
| 822 |
4170 |
XWikiContext xcontext = getContext(); |
| 823 |
|
|
| 824 |
|
|
| 825 |
4170 |
XWikiDocument.backupContext(backupObjects, xcontext); |
| 826 |
|
|
| 827 |
|
|
| 828 |
4170 |
xcontext = getContext(); |
| 829 |
|
|
| 830 |
|
|
| 831 |
4170 |
((XWikiDocument) document).setAsContextDoc(xcontext); |
| 832 |
|
} |
| 833 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 834 |
0 |
@Override... |
| 835 |
|
public String getCurrentWiki() |
| 836 |
|
{ |
| 837 |
0 |
XWikiContext xcontext = getContext(); |
| 838 |
0 |
return xcontext.getWikiId(); |
| 839 |
|
} |
| 840 |
|
|
| 841 |
|
|
| 842 |
|
|
| 843 |
|
|
| 844 |
|
@param |
| 845 |
|
@param |
| 846 |
|
@return |
| 847 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 848 |
2992 |
private boolean hasRight(DocumentReference documentReference, String right)... |
| 849 |
|
{ |
| 850 |
2992 |
return hasRight(this.defaultEntityReferenceSerializer.serialize(documentReference), right); |
| 851 |
|
} |
| 852 |
|
|
| 853 |
|
|
| 854 |
|
|
| 855 |
|
|
| 856 |
|
@param |
| 857 |
|
@param |
| 858 |
|
@return |
| 859 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 860 |
2992 |
private boolean hasRight(String documentReference, String right)... |
| 861 |
|
{ |
| 862 |
2992 |
boolean hasRight = false; |
| 863 |
2991 |
XWikiContext xcontext = getContext(); |
| 864 |
2992 |
try { |
| 865 |
2992 |
hasRight = |
| 866 |
|
xcontext.getWiki().getRightService() |
| 867 |
|
.hasAccessLevel(right, xcontext.getUser(), documentReference, xcontext); |
| 868 |
|
} catch (XWikiException e) { |
| 869 |
|
|
| 870 |
|
} |
| 871 |
2992 |
return hasRight; |
| 872 |
|
} |
| 873 |
|
|
| 874 |
|
|
| 875 |
|
@link |
| 876 |
|
|
| 877 |
|
|
| 878 |
|
@param@link |
| 879 |
|
@param |
| 880 |
|
@param |
| 881 |
|
@throws |
| 882 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 883 |
0 |
private void saveDocument(XWikiDocument doc, String comment, boolean isMinorEdit) throws Exception... |
| 884 |
|
{ |
| 885 |
0 |
doc.setAuthorReference(getContext().getUserReference()); |
| 886 |
0 |
if (doc.isNew()) { |
| 887 |
0 |
doc.setCreatorReference(getContext().getUserReference()); |
| 888 |
|
} |
| 889 |
0 |
getContext().getWiki().saveDocument(doc, comment, isMinorEdit, getContext()); |
| 890 |
|
} |
| 891 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 892 |
0 |
private String extractSpacesFromDocumentReference(DocumentReference reference)... |
| 893 |
|
{ |
| 894 |
|
|
| 895 |
|
|
| 896 |
0 |
EntityReference spaceReference = reference.getLastSpaceReference().removeParent(reference.getWikiReference()); |
| 897 |
0 |
return this.defaultEntityReferenceSerializer.serialize(spaceReference); |
| 898 |
|
} |
| 899 |
|
} |