| 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.IOException; |
| 24 |
|
import java.io.InputStream; |
| 25 |
|
import java.io.OutputStream; |
| 26 |
|
import java.io.StringWriter; |
| 27 |
|
import java.lang.ref.SoftReference; |
| 28 |
|
import java.lang.reflect.Constructor; |
| 29 |
|
import java.lang.reflect.Method; |
| 30 |
|
import java.lang.reflect.Type; |
| 31 |
|
import java.net.URL; |
| 32 |
|
import java.security.MessageDigest; |
| 33 |
|
import java.security.NoSuchAlgorithmException; |
| 34 |
|
import java.util.ArrayList; |
| 35 |
|
import java.util.Collection; |
| 36 |
|
import java.util.Collections; |
| 37 |
|
import java.util.Date; |
| 38 |
|
import java.util.HashMap; |
| 39 |
|
import java.util.HashSet; |
| 40 |
|
import java.util.Iterator; |
| 41 |
|
import java.util.LinkedHashSet; |
| 42 |
|
import java.util.List; |
| 43 |
|
import java.util.Locale; |
| 44 |
|
import java.util.Map; |
| 45 |
|
import java.util.Map.Entry; |
| 46 |
|
import java.util.Objects; |
| 47 |
|
import java.util.Set; |
| 48 |
|
import java.util.SortedMap; |
| 49 |
|
import java.util.TreeMap; |
| 50 |
|
import java.util.Vector; |
| 51 |
|
import java.util.regex.Matcher; |
| 52 |
|
import java.util.regex.Pattern; |
| 53 |
|
import java.util.zip.ZipEntry; |
| 54 |
|
import java.util.zip.ZipOutputStream; |
| 55 |
|
|
| 56 |
|
import javax.inject.Provider; |
| 57 |
|
import javax.servlet.http.HttpServletResponse; |
| 58 |
|
|
| 59 |
|
import org.apache.commons.lang3.BooleanUtils; |
| 60 |
|
import org.apache.commons.lang3.ObjectUtils; |
| 61 |
|
import org.apache.commons.lang3.StringUtils; |
| 62 |
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
| 63 |
|
import org.apache.velocity.VelocityContext; |
| 64 |
|
import org.dom4j.Document; |
| 65 |
|
import org.dom4j.Element; |
| 66 |
|
import org.dom4j.dom.DOMDocument; |
| 67 |
|
import org.dom4j.io.DocumentResult; |
| 68 |
|
import org.dom4j.io.OutputFormat; |
| 69 |
|
import org.slf4j.Logger; |
| 70 |
|
import org.slf4j.LoggerFactory; |
| 71 |
|
import org.suigeneris.jrcs.diff.Diff; |
| 72 |
|
import org.suigeneris.jrcs.diff.DifferentiationFailedException; |
| 73 |
|
import org.suigeneris.jrcs.diff.Revision; |
| 74 |
|
import org.suigeneris.jrcs.diff.delta.Delta; |
| 75 |
|
import org.suigeneris.jrcs.rcs.Version; |
| 76 |
|
import org.suigeneris.jrcs.util.ToString; |
| 77 |
|
import org.xwiki.bridge.DocumentModelBridge; |
| 78 |
|
import org.xwiki.component.util.DefaultParameterizedType; |
| 79 |
|
import org.xwiki.context.Execution; |
| 80 |
|
import org.xwiki.context.ExecutionContextException; |
| 81 |
|
import org.xwiki.context.ExecutionContextManager; |
| 82 |
|
import org.xwiki.display.internal.DocumentDisplayer; |
| 83 |
|
import org.xwiki.display.internal.DocumentDisplayerParameters; |
| 84 |
|
import org.xwiki.filter.input.DefaultInputStreamInputSource; |
| 85 |
|
import org.xwiki.filter.input.InputSource; |
| 86 |
|
import org.xwiki.filter.input.StringInputSource; |
| 87 |
|
import org.xwiki.filter.instance.input.DocumentInstanceInputProperties; |
| 88 |
|
import org.xwiki.filter.instance.output.DocumentInstanceOutputProperties; |
| 89 |
|
import org.xwiki.filter.output.DefaultOutputStreamOutputTarget; |
| 90 |
|
import org.xwiki.filter.output.DefaultWriterOutputTarget; |
| 91 |
|
import org.xwiki.filter.output.OutputTarget; |
| 92 |
|
import org.xwiki.filter.xar.input.XARInputProperties; |
| 93 |
|
import org.xwiki.filter.xar.output.XAROutputProperties; |
| 94 |
|
import org.xwiki.filter.xml.output.DefaultResultOutputTarget; |
| 95 |
|
import org.xwiki.job.event.status.JobProgressManager; |
| 96 |
|
import org.xwiki.localization.ContextualLocalizationManager; |
| 97 |
|
import org.xwiki.localization.LocaleUtils; |
| 98 |
|
import org.xwiki.model.EntityType; |
| 99 |
|
import org.xwiki.model.internal.reference.DefaultSymbolScheme; |
| 100 |
|
import org.xwiki.model.internal.reference.LocalStringEntityReferenceSerializer; |
| 101 |
|
import org.xwiki.model.internal.reference.LocalUidStringEntityReferenceSerializer; |
| 102 |
|
import org.xwiki.model.reference.AttachmentReference; |
| 103 |
|
import org.xwiki.model.reference.DocumentReference; |
| 104 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
| 105 |
|
import org.xwiki.model.reference.EntityReference; |
| 106 |
|
import org.xwiki.model.reference.EntityReferenceProvider; |
| 107 |
|
import org.xwiki.model.reference.EntityReferenceResolver; |
| 108 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
| 109 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
| 110 |
|
import org.xwiki.model.reference.ObjectPropertyReference; |
| 111 |
|
import org.xwiki.model.reference.ObjectReference; |
| 112 |
|
import org.xwiki.model.reference.ObjectReferenceResolver; |
| 113 |
|
import org.xwiki.model.reference.SpaceReference; |
| 114 |
|
import org.xwiki.model.reference.WikiReference; |
| 115 |
|
import org.xwiki.query.Query; |
| 116 |
|
import org.xwiki.query.QueryException; |
| 117 |
|
import org.xwiki.query.QueryFilter; |
| 118 |
|
import org.xwiki.rendering.block.Block; |
| 119 |
|
import org.xwiki.rendering.block.Block.Axes; |
| 120 |
|
import org.xwiki.rendering.block.HeaderBlock; |
| 121 |
|
import org.xwiki.rendering.block.LinkBlock; |
| 122 |
|
import org.xwiki.rendering.block.MacroBlock; |
| 123 |
|
import org.xwiki.rendering.block.SectionBlock; |
| 124 |
|
import org.xwiki.rendering.block.XDOM; |
| 125 |
|
import org.xwiki.rendering.block.match.ClassBlockMatcher; |
| 126 |
|
import org.xwiki.rendering.block.match.MacroBlockMatcher; |
| 127 |
|
import org.xwiki.rendering.listener.reference.ResourceReference; |
| 128 |
|
import org.xwiki.rendering.listener.reference.ResourceType; |
| 129 |
|
import org.xwiki.rendering.parser.ContentParser; |
| 130 |
|
import org.xwiki.rendering.parser.MissingParserException; |
| 131 |
|
import org.xwiki.rendering.parser.ParseException; |
| 132 |
|
import org.xwiki.rendering.parser.Parser; |
| 133 |
|
import org.xwiki.rendering.renderer.BlockRenderer; |
| 134 |
|
import org.xwiki.rendering.renderer.printer.DefaultWikiPrinter; |
| 135 |
|
import org.xwiki.rendering.renderer.printer.WikiPrinter; |
| 136 |
|
import org.xwiki.rendering.syntax.Syntax; |
| 137 |
|
import org.xwiki.rendering.syntax.SyntaxFactory; |
| 138 |
|
import org.xwiki.rendering.transformation.RenderingContext; |
| 139 |
|
import org.xwiki.rendering.transformation.TransformationContext; |
| 140 |
|
import org.xwiki.rendering.transformation.TransformationException; |
| 141 |
|
import org.xwiki.rendering.transformation.TransformationManager; |
| 142 |
|
import org.xwiki.rendering.util.ErrorBlockGenerator; |
| 143 |
|
import org.xwiki.security.authorization.ContextualAuthorizationManager; |
| 144 |
|
import org.xwiki.security.authorization.Right; |
| 145 |
|
import org.xwiki.velocity.VelocityManager; |
| 146 |
|
import org.xwiki.xar.internal.model.XarDocumentModel; |
| 147 |
|
import org.xwiki.xml.XMLUtils; |
| 148 |
|
|
| 149 |
|
import com.xpn.xwiki.CoreConfiguration; |
| 150 |
|
import com.xpn.xwiki.XWiki; |
| 151 |
|
import com.xpn.xwiki.XWikiConstant; |
| 152 |
|
import com.xpn.xwiki.XWikiContext; |
| 153 |
|
import com.xpn.xwiki.XWikiException; |
| 154 |
|
import com.xpn.xwiki.api.DocumentSection; |
| 155 |
|
import com.xpn.xwiki.criteria.impl.RevisionCriteria; |
| 156 |
|
import com.xpn.xwiki.doc.merge.MergeConfiguration; |
| 157 |
|
import com.xpn.xwiki.doc.merge.MergeResult; |
| 158 |
|
import com.xpn.xwiki.doc.rcs.XWikiRCSNodeInfo; |
| 159 |
|
import com.xpn.xwiki.internal.AbstractNotifyOnUpdateList; |
| 160 |
|
import com.xpn.xwiki.internal.cache.rendering.RenderingCache; |
| 161 |
|
import com.xpn.xwiki.internal.filter.XWikiDocumentFilterUtils; |
| 162 |
|
import com.xpn.xwiki.internal.merge.MergeUtils; |
| 163 |
|
import com.xpn.xwiki.internal.render.LinkedResourceHelper; |
| 164 |
|
import com.xpn.xwiki.internal.render.OldRendering; |
| 165 |
|
import com.xpn.xwiki.internal.xml.DOMXMLWriter; |
| 166 |
|
import com.xpn.xwiki.internal.xml.XMLWriter; |
| 167 |
|
import com.xpn.xwiki.objects.BaseCollection; |
| 168 |
|
import com.xpn.xwiki.objects.BaseObject; |
| 169 |
|
import com.xpn.xwiki.objects.BaseObjectReference; |
| 170 |
|
import com.xpn.xwiki.objects.BaseProperty; |
| 171 |
|
import com.xpn.xwiki.objects.LargeStringProperty; |
| 172 |
|
import com.xpn.xwiki.objects.ListProperty; |
| 173 |
|
import com.xpn.xwiki.objects.ObjectDiff; |
| 174 |
|
import com.xpn.xwiki.objects.PropertyInterface; |
| 175 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
| 176 |
|
import com.xpn.xwiki.objects.classes.ListClass; |
| 177 |
|
import com.xpn.xwiki.objects.classes.PropertyClass; |
| 178 |
|
import com.xpn.xwiki.objects.classes.StaticListClass; |
| 179 |
|
import com.xpn.xwiki.objects.classes.TextAreaClass; |
| 180 |
|
import com.xpn.xwiki.store.XWikiAttachmentStoreInterface; |
| 181 |
|
import com.xpn.xwiki.store.XWikiStoreInterface; |
| 182 |
|
import com.xpn.xwiki.store.XWikiVersioningStoreInterface; |
| 183 |
|
import com.xpn.xwiki.user.api.XWikiRightService; |
| 184 |
|
import com.xpn.xwiki.util.Util; |
| 185 |
|
import com.xpn.xwiki.validation.XWikiValidationInterface; |
| 186 |
|
import com.xpn.xwiki.validation.XWikiValidationStatus; |
| 187 |
|
import com.xpn.xwiki.web.EditForm; |
| 188 |
|
import com.xpn.xwiki.web.ObjectAddForm; |
| 189 |
|
import com.xpn.xwiki.web.ObjectPolicyType; |
| 190 |
|
import com.xpn.xwiki.web.Utils; |
| 191 |
|
import com.xpn.xwiki.web.XWikiRequest; |
| 192 |
|
|
| |
|
| 67.6% |
Uncovered Elements: 1,315 (4,058) |
Complexity: 1,143 |
Complexity Density: 0.45 |
|
| 193 |
|
public class XWikiDocument implements DocumentModelBridge, Cloneable |
| 194 |
|
{ |
| 195 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(XWikiDocument.class); |
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
@version |
| 201 |
|
@since |
| 202 |
|
|
| |
|
| 41.2% |
Uncovered Elements: 10 (17) |
Complexity: 7 |
Complexity Density: 0.78 |
|
| 203 |
|
public static class XWikiAttachmentToRemove |
| 204 |
|
{ |
| 205 |
|
|
| 206 |
|
@see |
| 207 |
|
|
| 208 |
|
private XWikiAttachment attachment; |
| 209 |
|
|
| 210 |
|
|
| 211 |
|
@see |
| 212 |
|
|
| 213 |
|
private boolean toRecycleBin; |
| 214 |
|
|
| 215 |
|
|
| 216 |
|
@param |
| 217 |
|
@param |
| 218 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 219 |
8 |
public XWikiAttachmentToRemove(XWikiAttachment attachment, boolean toRecycleBin)... |
| 220 |
|
{ |
| 221 |
8 |
this.attachment = attachment; |
| 222 |
8 |
this.toRecycleBin = toRecycleBin; |
| 223 |
|
} |
| 224 |
|
|
| 225 |
|
|
| 226 |
|
@return |
| 227 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 228 |
10 |
public XWikiAttachment getAttachment()... |
| 229 |
|
{ |
| 230 |
10 |
return this.attachment; |
| 231 |
|
} |
| 232 |
|
|
| 233 |
|
|
| 234 |
|
@return |
| 235 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 236 |
5 |
public boolean isToRecycleBin()... |
| 237 |
|
{ |
| 238 |
5 |
return this.toRecycleBin; |
| 239 |
|
} |
| 240 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 241 |
0 |
@Override... |
| 242 |
|
public int hashCode() |
| 243 |
|
{ |
| 244 |
0 |
return this.attachment.hashCode(); |
| 245 |
|
} |
| 246 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 247 |
0 |
@Override... |
| 248 |
|
public boolean equals(Object obj) |
| 249 |
|
{ |
| 250 |
0 |
if (obj instanceof XWikiAttachmentToRemove) { |
| 251 |
0 |
return this.attachment.equals(((XWikiAttachmentToRemove) obj).getAttachment()); |
| 252 |
|
} |
| 253 |
|
|
| 254 |
0 |
return false; |
| 255 |
|
} |
| 256 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 257 |
0 |
@Override... |
| 258 |
|
public String toString() |
| 259 |
|
{ |
| 260 |
0 |
return this.attachment.toString(); |
| 261 |
|
} |
| 262 |
|
} |
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
private static final Pattern HTML_TAG_PATTERN = Pattern.compile( |
| 268 |
|
"</?+(html|img|a|i|br?|embed|script|form|input|textarea|object|font|li|[dou]l|table|center|hr|p) ?([^>]*+)>"); |
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
|
| 273 |
|
|
| 274 |
|
|
| 275 |
|
private static final Pattern XPROPERTY_REFERENCE_PATTERN = Pattern.compile("(.+?)_([0-9]+)_(.+)"); |
| 276 |
|
|
| 277 |
|
public static final EntityReference COMMENTSCLASS_REFERENCE = new LocalDocumentReference("XWiki", "XWikiComments"); |
| 278 |
|
|
| 279 |
|
public static final EntityReference SHEETCLASS_REFERENCE = new LocalDocumentReference("XWiki", "SheetClass"); |
| 280 |
|
|
| 281 |
|
public static final int HAS_ATTACHMENTS = 1; |
| 282 |
|
|
| 283 |
|
public static final int HAS_OBJECTS = 2; |
| 284 |
|
|
| 285 |
|
public static final int HAS_CLASS = 4; |
| 286 |
|
|
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
public static final String CKEY_SDOC = "sdoc"; |
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
|
| 295 |
|
public static final String DB_SPACE_SEP = ":"; |
| 296 |
|
|
| 297 |
|
|
| 298 |
|
|
| 299 |
|
|
| 300 |
|
public static final String SPACE_NAME_SEP = "."; |
| 301 |
|
|
| 302 |
|
private static final LocalStringEntityReferenceSerializer LOCAL_REFERENCE_SERIALIZER = |
| 303 |
|
new LocalStringEntityReferenceSerializer(new DefaultSymbolScheme()); |
| 304 |
|
|
| 305 |
|
|
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 309 |
159 |
private static DocumentReferenceResolver<String> getCurrentDocumentReferenceResolver()... |
| 310 |
|
{ |
| 311 |
159 |
return Utils.getComponent(DocumentReferenceResolver.TYPE_STRING, "current"); |
| 312 |
|
} |
| 313 |
|
|
| 314 |
|
|
| 315 |
|
|
| 316 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 317 |
47 |
private static EntityReferenceResolver<ResourceReference> getResourceReferenceEntityReferenceResolver()... |
| 318 |
|
{ |
| 319 |
47 |
return Utils |
| 320 |
|
.getComponent(new DefaultParameterizedType(null, EntityReferenceResolver.class, ResourceReference.class)); |
| 321 |
|
} |
| 322 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 323 |
20327 |
private static EntityReferenceResolver<String> getXClassEntityReferenceResolver()... |
| 324 |
|
{ |
| 325 |
20324 |
return Utils.getComponent(EntityReferenceResolver.TYPE_STRING, "xclass"); |
| 326 |
|
} |
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| 330 |
|
|
| 331 |
|
|
| 332 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 333 |
24601 |
private static DocumentReferenceResolver<String> getCurrentMixedDocumentReferenceResolver()... |
| 334 |
|
{ |
| 335 |
24603 |
return Utils.getComponent(DocumentReferenceResolver.TYPE_STRING, "currentmixed"); |
| 336 |
|
} |
| 337 |
|
|
| 338 |
|
|
| 339 |
|
|
| 340 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 341 |
103576 |
private static DocumentReferenceResolver<EntityReference> getCurrentReferenceDocumentReferenceResolver()... |
| 342 |
|
{ |
| 343 |
103570 |
return Utils.getComponent(DocumentReferenceResolver.TYPE_REFERENCE, "current"); |
| 344 |
|
} |
| 345 |
|
|
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 350 |
10737 |
private static EntityReferenceResolver<String> getRelativeEntityReferenceResolver()... |
| 351 |
|
{ |
| 352 |
10737 |
return Utils.getComponent(EntityReferenceResolver.TYPE_STRING, "relative"); |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
|
| 356 |
|
|
| 357 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 358 |
9 |
private static EntityReferenceSerializer<String> getCompactEntityReferenceSerializer()... |
| 359 |
|
{ |
| 360 |
9 |
return Utils.getComponent(EntityReferenceSerializer.TYPE_STRING, "compact"); |
| 361 |
|
} |
| 362 |
|
|
| 363 |
|
|
| 364 |
|
|
| 365 |
|
|
| 366 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 367 |
50694 |
private static EntityReferenceSerializer<String> getCompactWikiEntityReferenceSerializer()... |
| 368 |
|
{ |
| 369 |
50694 |
return Utils.getComponent(EntityReferenceSerializer.TYPE_STRING, "compactwiki"); |
| 370 |
|
} |
| 371 |
|
|
| 372 |
|
|
| 373 |
|
|
| 374 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 375 |
6718 |
private static ObjectReferenceResolver<EntityReference> getCurrentReferenceObjectReferenceResolver()... |
| 376 |
|
{ |
| 377 |
6713 |
return Utils.getComponent(ObjectReferenceResolver.TYPE_REFERENCE, "current"); |
| 378 |
|
} |
| 379 |
|
|
| 380 |
|
private String title; |
| 381 |
|
|
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
|
|
| 387 |
|
|
| 388 |
|
|
| 389 |
|
|
| 390 |
|
private EntityReference parentReference; |
| 391 |
|
|
| 392 |
|
private DocumentReference documentReference; |
| 393 |
|
|
| 394 |
|
private String content; |
| 395 |
|
|
| 396 |
|
private String meta; |
| 397 |
|
|
| 398 |
|
private String format; |
| 399 |
|
|
| 400 |
|
|
| 401 |
|
|
| 402 |
|
|
| 403 |
|
private DocumentReference creatorReference; |
| 404 |
|
|
| 405 |
|
|
| 406 |
|
|
| 407 |
|
|
| 408 |
|
private DocumentReference authorReference; |
| 409 |
|
|
| 410 |
|
|
| 411 |
|
|
| 412 |
|
|
| 413 |
|
|
| 414 |
|
|
| 415 |
|
|
| 416 |
|
private DocumentReference contentAuthorReference; |
| 417 |
|
|
| 418 |
|
private String customClass; |
| 419 |
|
|
| 420 |
|
private Date contentUpdateDate; |
| 421 |
|
|
| 422 |
|
private Date updateDate; |
| 423 |
|
|
| 424 |
|
private Date creationDate; |
| 425 |
|
|
| 426 |
|
protected Version version; |
| 427 |
|
|
| 428 |
|
private long id = 0; |
| 429 |
|
|
| 430 |
|
private boolean mostRecent = true; |
| 431 |
|
|
| 432 |
|
private boolean isNew = true; |
| 433 |
|
|
| 434 |
|
|
| 435 |
|
|
| 436 |
|
|
| 437 |
|
|
| 438 |
|
|
| 439 |
|
private DocumentReference templateDocumentReference; |
| 440 |
|
|
| 441 |
|
private Locale locale; |
| 442 |
|
|
| 443 |
|
private Locale defaultLocale; |
| 444 |
|
|
| 445 |
|
|
| 446 |
|
|
| 447 |
|
|
| 448 |
|
|
| 449 |
|
|
| 450 |
|
private boolean hidden = false; |
| 451 |
|
|
| 452 |
|
|
| 453 |
|
|
| 454 |
|
|
| 455 |
|
private String comment; |
| 456 |
|
|
| 457 |
|
|
| 458 |
|
|
| 459 |
|
|
| 460 |
|
|
| 461 |
|
private Syntax syntax; |
| 462 |
|
|
| 463 |
|
|
| 464 |
|
|
| 465 |
|
|
| 466 |
|
private boolean isMinorEdit = false; |
| 467 |
|
|
| 468 |
|
|
| 469 |
|
|
| 470 |
|
|
| 471 |
|
private boolean isContentDirty = true; |
| 472 |
|
|
| 473 |
|
|
| 474 |
|
|
| 475 |
|
|
| 476 |
|
private boolean isMetaDataDirty = true; |
| 477 |
|
|
| 478 |
|
private int elements = HAS_OBJECTS | HAS_ATTACHMENTS; |
| 479 |
|
|
| 480 |
|
|
| 481 |
|
private BaseClass xClass; |
| 482 |
|
|
| 483 |
|
private String xClassXML; |
| 484 |
|
|
| 485 |
|
|
| 486 |
|
|
| 487 |
|
|
| 488 |
|
|
| 489 |
|
|
| 490 |
|
private Map<DocumentReference, List<BaseObject>> xObjects = new TreeMap<DocumentReference, List<BaseObject>>(); |
| 491 |
|
|
| 492 |
|
private final List<XWikiAttachment> attachmentList = |
| 493 |
|
new AbstractNotifyOnUpdateList<XWikiAttachment>(new ArrayList<XWikiAttachment>()) |
| 494 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 495 |
88678 |
@Override... |
| 496 |
|
public void onUpdate() |
| 497 |
|
{ |
| 498 |
88674 |
setMetaDataDirty(true); |
| 499 |
|
} |
| 500 |
|
}; |
| 501 |
|
|
| 502 |
|
|
| 503 |
|
private boolean fromCache = false; |
| 504 |
|
|
| 505 |
|
private List<BaseObject> xObjectsToRemove = new ArrayList<BaseObject>(); |
| 506 |
|
|
| 507 |
|
private List<XWikiAttachmentToRemove> attachmentsToRemove = new ArrayList<XWikiAttachmentToRemove>(); |
| 508 |
|
|
| 509 |
|
|
| 510 |
|
|
| 511 |
|
|
| 512 |
|
@see |
| 513 |
|
|
| 514 |
|
private String defaultTemplate; |
| 515 |
|
|
| 516 |
|
private String validationScript; |
| 517 |
|
|
| 518 |
|
private Object wikiNode; |
| 519 |
|
|
| 520 |
|
|
| 521 |
|
|
| 522 |
|
|
| 523 |
|
|
| 524 |
|
private SoftReference<XWikiDocumentArchive> archive; |
| 525 |
|
|
| 526 |
|
private XWikiStoreInterface store; |
| 527 |
|
|
| 528 |
|
|
| 529 |
|
@see |
| 530 |
|
|
| 531 |
|
private XWikiDocument originalDocument; |
| 532 |
|
|
| 533 |
|
|
| 534 |
|
|
| 535 |
|
|
| 536 |
|
|
| 537 |
|
|
| 538 |
|
private DocumentDisplayer documentDisplayer; |
| 539 |
|
|
| 540 |
|
|
| 541 |
|
@see |
| 542 |
|
|
| 543 |
|
private EntityReferenceSerializer<String> defaultEntityReferenceSerializer; |
| 544 |
|
|
| 545 |
|
|
| 546 |
|
@see |
| 547 |
|
|
| 548 |
|
private DocumentReferenceResolver<String> explicitDocumentReferenceResolver; |
| 549 |
|
|
| 550 |
|
|
| 551 |
|
@see |
| 552 |
|
|
| 553 |
|
private DocumentReferenceResolver<EntityReference> explicitReferenceDocumentReferenceResolver; |
| 554 |
|
|
| 555 |
|
|
| 556 |
|
@see |
| 557 |
|
|
| 558 |
|
private EntityReferenceSerializer<String> uidStringEntityReferenceSerializer; |
| 559 |
|
|
| 560 |
|
private Provider<OldRendering> oldRenderingProvider; |
| 561 |
|
|
| 562 |
|
private JobProgressManager progress; |
| 563 |
|
|
| 564 |
|
|
| 565 |
|
@see |
| 566 |
|
|
| 567 |
|
private SyntaxFactory syntaxFactory; |
| 568 |
|
|
| 569 |
|
private ContextualLocalizationManager localization; |
| 570 |
|
|
| 571 |
|
|
| 572 |
|
|
| 573 |
|
|
| 574 |
|
|
| 575 |
|
private XDOM xdomCache; |
| 576 |
|
|
| 577 |
|
|
| 578 |
|
|
| 579 |
|
|
| 580 |
|
|
| 581 |
|
|
| 582 |
|
private RenderingCache renderingCache; |
| 583 |
|
|
| 584 |
|
|
| 585 |
|
|
| 586 |
|
|
| 587 |
|
|
| 588 |
|
private DocumentReference parentReferenceCache; |
| 589 |
|
|
| 590 |
|
|
| 591 |
|
@see |
| 592 |
|
|
| 593 |
|
private String keyCache; |
| 594 |
|
|
| 595 |
|
|
| 596 |
|
@see |
| 597 |
|
|
| 598 |
|
private String localKeyCache; |
| 599 |
|
|
| 600 |
|
private RenderingContext renderingContext; |
| 601 |
|
|
| 602 |
|
|
| 603 |
|
@since |
| 604 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 605 |
250351 |
public XWikiDocument(DocumentReference reference)... |
| 606 |
|
{ |
| 607 |
250352 |
init(reference); |
| 608 |
|
} |
| 609 |
|
|
| 610 |
|
|
| 611 |
|
@since |
| 612 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 613 |
1057350 |
public XWikiDocument(DocumentReference reference, Locale locale)... |
| 614 |
|
{ |
| 615 |
1057334 |
init(reference); |
| 616 |
|
|
| 617 |
1057324 |
this.locale = locale; |
| 618 |
|
} |
| 619 |
|
|
| 620 |
|
|
| 621 |
|
@deprecated@link |
| 622 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 623 |
21888 |
@Deprecated... |
| 624 |
|
public XWikiDocument() |
| 625 |
|
{ |
| 626 |
21888 |
this(null); |
| 627 |
|
} |
| 628 |
|
|
| 629 |
|
|
| 630 |
|
@link |
| 631 |
|
|
| 632 |
|
|
| 633 |
|
@param |
| 634 |
|
@param |
| 635 |
|
@deprecated@link |
| 636 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 637 |
86 |
@Deprecated... |
| 638 |
|
public XWikiDocument(String space, String name) |
| 639 |
|
{ |
| 640 |
86 |
this(null, space, name); |
| 641 |
|
} |
| 642 |
|
|
| 643 |
|
|
| 644 |
|
|
| 645 |
|
|
| 646 |
|
@param |
| 647 |
|
@param |
| 648 |
|
@param |
| 649 |
|
@deprecated@link |
| 650 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 651 |
88 |
@Deprecated... |
| 652 |
|
public XWikiDocument(String wiki, String space, String name) |
| 653 |
|
{ |
| 654 |
|
|
| 655 |
|
|
| 656 |
|
|
| 657 |
|
|
| 658 |
|
|
| 659 |
88 |
EntityReference contextReference = null; |
| 660 |
88 |
if (!StringUtils.isEmpty(space)) { |
| 661 |
88 |
contextReference = new EntityReference(space, EntityType.SPACE); |
| 662 |
|
} |
| 663 |
|
|
| 664 |
88 |
DocumentReference reference = getCurrentDocumentReferenceResolver().resolve(name, contextReference); |
| 665 |
|
|
| 666 |
88 |
if (!StringUtils.isEmpty(wiki)) { |
| 667 |
2 |
reference = reference.replaceParent(reference.getWikiReference(), new WikiReference(wiki)); |
| 668 |
|
} |
| 669 |
|
|
| 670 |
88 |
init(reference); |
| 671 |
|
} |
| 672 |
|
|
| 673 |
|
|
| 674 |
|
|
| 675 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 676 |
39629 |
private DocumentReferenceResolver<String> getExplicitDocumentReferenceResolver()... |
| 677 |
|
{ |
| 678 |
39625 |
if (this.explicitDocumentReferenceResolver == null) { |
| 679 |
18430 |
this.explicitDocumentReferenceResolver = |
| 680 |
|
Utils.getComponent(DocumentReferenceResolver.TYPE_STRING, "explicit"); |
| 681 |
|
} |
| 682 |
|
|
| 683 |
39625 |
return this.explicitDocumentReferenceResolver; |
| 684 |
|
} |
| 685 |
|
|
| 686 |
|
|
| 687 |
|
|
| 688 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 689 |
20058 |
private DocumentReferenceResolver<EntityReference> getExplicitReferenceDocumentReferenceResolver()... |
| 690 |
|
{ |
| 691 |
20058 |
if (this.explicitReferenceDocumentReferenceResolver == null) { |
| 692 |
7470 |
this.explicitReferenceDocumentReferenceResolver = |
| 693 |
|
Utils.getComponent(DocumentReferenceResolver.TYPE_REFERENCE, "explicit"); |
| 694 |
|
} |
| 695 |
|
|
| 696 |
20059 |
return this.explicitReferenceDocumentReferenceResolver; |
| 697 |
|
} |
| 698 |
|
|
| 699 |
|
|
| 700 |
|
|
| 701 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 702 |
58102 |
private EntityReferenceSerializer<String> getDefaultEntityReferenceSerializer()... |
| 703 |
|
{ |
| 704 |
58102 |
if (this.defaultEntityReferenceSerializer == null) { |
| 705 |
34140 |
this.defaultEntityReferenceSerializer = Utils.getComponent(EntityReferenceSerializer.TYPE_STRING); |
| 706 |
|
} |
| 707 |
|
|
| 708 |
58102 |
return this.defaultEntityReferenceSerializer; |
| 709 |
|
} |
| 710 |
|
|
| 711 |
|
|
| 712 |
|
|
| 713 |
|
|
| |
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 714 |
8 |
private EntityReferenceSerializer<String> getUidStringEntityReferenceSerializer()... |
| 715 |
|
{ |
| 716 |
8 |
if (this.uidStringEntityReferenceSerializer == null) { |
| 717 |
8 |
this.uidStringEntityReferenceSerializer = Utils.getComponent(EntityReferenceSerializer.TYPE_STRING, "uid"); |
| 718 |
|
} |
| 719 |
|
|
| 720 |
8 |
return this.uidStringEntityReferenceSerializer; |
| 721 |
|
} |
| 722 |
|
|
| 723 |
|
|
| 724 |
|
@link |
| 725 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 726 |
4119 |
private SyntaxFactory getSyntaxFactory()... |
| 727 |
|
{ |
| 728 |
4118 |
if (this.syntaxFactory == null) { |
| 729 |
3781 |
this.syntaxFactory = Utils.getComponent((Type) SyntaxFactory.class); |
| 730 |
|
} |
| 731 |
|
|
| 732 |
4118 |
return this.syntaxFactory; |
| 733 |
|
} |
| 734 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 735 |
5 |
private ContextualLocalizationManager getLocalization()... |
| 736 |
|
{ |
| 737 |
5 |
if (this.localization == null) { |
| 738 |
1 |
this.localization = Utils.getComponent(ContextualLocalizationManager.class); |
| 739 |
|
} |
| 740 |
|
|
| 741 |
5 |
return this.localization; |
| 742 |
|
} |
| 743 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 744 |
3 |
private OldRendering getOldRendering()... |
| 745 |
|
{ |
| 746 |
3 |
if (this.oldRenderingProvider == null) { |
| 747 |
1 |
this.oldRenderingProvider = Utils.getComponent(OldRendering.TYPE_PROVIDER); |
| 748 |
|
} |
| 749 |
|
|
| 750 |
3 |
return this.oldRenderingProvider.get(); |
| 751 |
|
} |
| 752 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 753 |
43827 |
private JobProgressManager getProgress()... |
| 754 |
|
{ |
| 755 |
43827 |
if (this.progress == null) { |
| 756 |
799 |
this.progress = Utils.getComponent(JobProgressManager.class); |
| 757 |
|
} |
| 758 |
|
|
| 759 |
43825 |
return this.progress; |
| 760 |
|
} |
| 761 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 762 |
5 |
private String localizePlainOrKey(String key, Object... parameters)... |
| 763 |
|
{ |
| 764 |
5 |
return StringUtils.defaultString(getLocalization().getTranslationPlain(key, parameters), key); |
| 765 |
|
} |
| 766 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 767 |
2639 |
public XWikiStoreInterface getStore(XWikiContext context)... |
| 768 |
|
{ |
| 769 |
2639 |
return context.getWiki().getStore(); |
| 770 |
|
} |
| 771 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 772 |
0 |
public XWikiAttachmentStoreInterface getAttachmentStore(XWikiContext context)... |
| 773 |
|
{ |
| 774 |
0 |
return context.getWiki().getAttachmentStore(); |
| 775 |
|
} |
| 776 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 777 |
6410 |
public XWikiVersioningStoreInterface getVersioningStore(XWikiContext context)... |
| 778 |
|
{ |
| 779 |
6410 |
return context.getWiki().getVersioningStore(); |
| 780 |
|
} |
| 781 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 782 |
37404 |
public XWikiStoreInterface getStore()... |
| 783 |
|
{ |
| 784 |
37406 |
return this.store; |
| 785 |
|
} |
| 786 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 787 |
489974 |
public void setStore(XWikiStoreInterface store)... |
| 788 |
|
{ |
| 789 |
489953 |
this.store = store; |
| 790 |
|
} |
| 791 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 792 |
16791 |
private RenderingContext getRenderingContext()... |
| 793 |
|
{ |
| 794 |
16793 |
if (this.renderingContext == null) { |
| 795 |
7716 |
this.renderingContext = Utils.getComponent(RenderingContext.class); |
| 796 |
|
} |
| 797 |
|
|
| 798 |
16790 |
return this.renderingContext; |
| 799 |
|
} |
| 800 |
|
|
| 801 |
|
|
| 802 |
|
|
| 803 |
|
|
| 804 |
|
|
| 805 |
|
@return |
| 806 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 807 |
37736 |
private String getLocalKey()... |
| 808 |
|
{ |
| 809 |
37736 |
if (this.localKeyCache == null) { |
| 810 |
15091 |
this.localKeyCache = |
| 811 |
|
LocalUidStringEntityReferenceSerializer.INSTANCE.serialize(getDocumentReferenceWithLocale()); |
| 812 |
|
} |
| 813 |
|
|
| 814 |
37740 |
return this.localKeyCache; |
| 815 |
|
} |
| 816 |
|
|
| 817 |
|
|
| 818 |
|
|
| 819 |
|
|
| 820 |
|
|
| 821 |
|
@return |
| 822 |
|
@since |
| 823 |
|
|
| |
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 824 |
8 |
public String getKey()... |
| 825 |
|
{ |
| 826 |
8 |
if (this.keyCache == null) { |
| 827 |
8 |
this.keyCache = getUidStringEntityReferenceSerializer().serialize(getDocumentReferenceWithLocale()); |
| 828 |
|
} |
| 829 |
|
|
| 830 |
8 |
return this.keyCache; |
| 831 |
|
} |
| 832 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 833 |
440 |
@Override... |
| 834 |
|
public int hashCode() |
| 835 |
|
{ |
| 836 |
440 |
return (int) Util.getHash(getLocalKey()); |
| 837 |
|
} |
| 838 |
|
|
| 839 |
|
|
| 840 |
|
@return |
| 841 |
|
|
| 842 |
|
|
| 843 |
|
|
| 844 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 845 |
37310 |
public long getId()... |
| 846 |
|
{ |
| 847 |
|
|
| 848 |
|
|
| 849 |
|
|
| 850 |
|
|
| 851 |
|
|
| 852 |
|
|
| 853 |
|
|
| 854 |
|
|
| 855 |
|
|
| 856 |
37307 |
this.id = Util.getHash(getLocalKey()); |
| 857 |
|
|
| 858 |
37301 |
return this.id; |
| 859 |
|
} |
| 860 |
|
|
| 861 |
|
|
| 862 |
|
@see |
| 863 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 864 |
14459 |
public void setId(long id)... |
| 865 |
|
{ |
| 866 |
14468 |
this.id = id; |
| 867 |
|
} |
| 868 |
|
|
| 869 |
|
|
| 870 |
|
|
| 871 |
|
|
| 872 |
|
|
| 873 |
|
|
| 874 |
|
|
| 875 |
|
@return |
| 876 |
|
@deprecated@link |
| 877 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 878 |
73865 |
@Deprecated... |
| 879 |
|
public String getSpace() |
| 880 |
|
{ |
| 881 |
73863 |
return LOCAL_REFERENCE_SERIALIZER.serialize(getDocumentReference().getLastSpaceReference()); |
| 882 |
|
} |
| 883 |
|
|
| 884 |
|
|
| 885 |
|
|
| 886 |
|
|
| 887 |
|
|
| 888 |
|
|
| 889 |
|
@see |
| 890 |
|
@deprecated@link |
| 891 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 892 |
7286 |
@Deprecated... |
| 893 |
|
public void setSpace(String spaces) |
| 894 |
|
{ |
| 895 |
7287 |
if (spaces != null) { |
| 896 |
7287 |
DocumentReference reference = getDocumentReference(); |
| 897 |
7287 |
EntityReference spaceReference = getRelativeEntityReferenceResolver().resolve(spaces, EntityType.SPACE); |
| 898 |
7289 |
spaceReference = spaceReference.appendParent(getDocumentReference().getWikiReference()); |
| 899 |
7289 |
setDocumentReferenceInternal( |
| 900 |
|
new DocumentReference(reference.getName(), new SpaceReference(spaceReference))); |
| 901 |
|
} |
| 902 |
|
} |
| 903 |
|
|
| 904 |
|
|
| 905 |
|
|
| 906 |
|
|
| 907 |
|
@return |
| 908 |
|
@see |
| 909 |
|
@deprecated@link |
| 910 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 911 |
7972 |
@Deprecated... |
| 912 |
|
public String getWeb() |
| 913 |
|
{ |
| 914 |
7972 |
return getSpace(); |
| 915 |
|
} |
| 916 |
|
|
| 917 |
|
|
| 918 |
|
|
| 919 |
|
|
| 920 |
|
@deprecated@link |
| 921 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 922 |
3642 |
@Deprecated... |
| 923 |
|
public void setWeb(String space) |
| 924 |
|
{ |
| 925 |
3643 |
setSpace(space); |
| 926 |
|
} |
| 927 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 928 |
47273 |
@Override... |
| 929 |
|
public String getVersion() |
| 930 |
|
{ |
| 931 |
47273 |
return getRCSVersion().toString(); |
| 932 |
|
} |
| 933 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 934 |
5765 |
public void setVersion(String version)... |
| 935 |
|
{ |
| 936 |
5765 |
if (!StringUtils.isEmpty(version)) { |
| 937 |
5765 |
this.version = new Version(version); |
| 938 |
|
} |
| 939 |
|
} |
| 940 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 941 |
55987 |
public Version getRCSVersion()... |
| 942 |
|
{ |
| 943 |
55987 |
if (this.version == null) { |
| 944 |
733 |
return new Version("1.1"); |
| 945 |
|
} |
| 946 |
55254 |
return this.version; |
| 947 |
|
} |
| 948 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 949 |
5769 |
public void setRCSVersion(Version version)... |
| 950 |
|
{ |
| 951 |
5769 |
this.version = version; |
| 952 |
|
} |
| 953 |
|
|
| 954 |
|
|
| 955 |
|
@return |
| 956 |
|
|
| 957 |
|
|
| 958 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 959 |
33147 |
@Override... |
| 960 |
|
public XWikiDocument getOriginalDocument() |
| 961 |
|
{ |
| 962 |
33147 |
return this.originalDocument; |
| 963 |
|
} |
| 964 |
|
|
| 965 |
|
|
| 966 |
|
@param |
| 967 |
|
|
| 968 |
|
@see |
| 969 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 970 |
454398 |
public void setOriginalDocument(XWikiDocument originalDocument)... |
| 971 |
|
{ |
| 972 |
454390 |
this.originalDocument = originalDocument; |
| 973 |
|
} |
| 974 |
|
|
| 975 |
|
|
| 976 |
|
@return |
| 977 |
|
@since |
| 978 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 979 |
20928 |
public DocumentReference getParentReference()... |
| 980 |
|
{ |
| 981 |
|
|
| 982 |
|
|
| 983 |
20929 |
if (this.parentReferenceCache == null && getRelativeParentReference() != null) { |
| 984 |
5230 |
this.parentReferenceCache = getExplicitReferenceDocumentReferenceResolver() |
| 985 |
|
.resolve(getRelativeParentReference(), getDocumentReference()); |
| 986 |
|
} |
| 987 |
|
|
| 988 |
20930 |
return this.parentReferenceCache; |
| 989 |
|
} |
| 990 |
|
|
| 991 |
|
|
| 992 |
|
|
| 993 |
|
|
| 994 |
|
@return |
| 995 |
|
|
| 996 |
|
@see |
| 997 |
|
@deprecated@link |
| 998 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 999 |
15650 |
@Deprecated... |
| 1000 |
|
public String getParent() |
| 1001 |
|
{ |
| 1002 |
15650 |
String parentReferenceAsString; |
| 1003 |
15652 |
if (getParentReference() != null) { |
| 1004 |
8647 |
parentReferenceAsString = getDefaultEntityReferenceSerializer().serialize(getRelativeParentReference()); |
| 1005 |
|
} else { |
| 1006 |
7004 |
parentReferenceAsString = ""; |
| 1007 |
|
} |
| 1008 |
15651 |
return parentReferenceAsString; |
| 1009 |
|
} |
| 1010 |
|
|
| 1011 |
|
|
| 1012 |
|
@deprecated@link |
| 1013 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1014 |
0 |
@Deprecated... |
| 1015 |
|
public XWikiDocument getParentDoc() |
| 1016 |
|
{ |
| 1017 |
0 |
return new XWikiDocument(getParentReference()); |
| 1018 |
|
} |
| 1019 |
|
|
| 1020 |
|
|
| 1021 |
|
@since |
| 1022 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 1023 |
43853 |
public void setParentReference(EntityReference parentReference)... |
| 1024 |
|
{ |
| 1025 |
43852 |
if (!Objects.equals(getRelativeParentReference(), parentReference)) { |
| 1026 |
24922 |
this.parentReference = parentReference; |
| 1027 |
|
|
| 1028 |
|
|
| 1029 |
24919 |
this.parentReferenceCache = null; |
| 1030 |
|
|
| 1031 |
24920 |
setMetaDataDirty(true); |
| 1032 |
|
} |
| 1033 |
|
} |
| 1034 |
|
|
| 1035 |
|
|
| 1036 |
|
|
| 1037 |
|
|
| 1038 |
|
@param |
| 1039 |
|
@deprecated@link |
| 1040 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1041 |
3778 |
@Deprecated... |
| 1042 |
|
public void setParent(String parent) |
| 1043 |
|
{ |
| 1044 |
|
|
| 1045 |
|
|
| 1046 |
|
|
| 1047 |
3779 |
if (StringUtils.isEmpty(parent)) { |
| 1048 |
330 |
setParentReference((EntityReference) null); |
| 1049 |
|
} else { |
| 1050 |
3448 |
setParentReference(getRelativeEntityReferenceResolver().resolve(parent, EntityType.DOCUMENT)); |
| 1051 |
|
} |
| 1052 |
|
} |
| 1053 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1054 |
67830 |
@Override... |
| 1055 |
|
public String getContent() |
| 1056 |
|
{ |
| 1057 |
67830 |
return this.content; |
| 1058 |
|
} |
| 1059 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 1060 |
38314 |
public void setContent(String content)... |
| 1061 |
|
{ |
| 1062 |
38317 |
if (content == null) { |
| 1063 |
0 |
content = ""; |
| 1064 |
|
} |
| 1065 |
|
|
| 1066 |
38316 |
boolean notEqual = !content.equals(this.content); |
| 1067 |
|
|
| 1068 |
38318 |
this.content = content; |
| 1069 |
|
|
| 1070 |
38314 |
if (notEqual) { |
| 1071 |
|
|
| 1072 |
13983 |
this.xdomCache = null; |
| 1073 |
13983 |
setContentDirty(true); |
| 1074 |
13983 |
setWikiNode(null); |
| 1075 |
|
} |
| 1076 |
|
} |
| 1077 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1078 |
5 |
public void setContent(XDOM content) throws XWikiException... |
| 1079 |
|
{ |
| 1080 |
5 |
setContent(renderXDOM(content, getSyntax())); |
| 1081 |
|
} |
| 1082 |
|
|
| 1083 |
|
|
| 1084 |
|
@return |
| 1085 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1086 |
12384 |
private RenderingCache getRenderingCache()... |
| 1087 |
|
{ |
| 1088 |
12385 |
if (this.renderingCache == null) { |
| 1089 |
667 |
this.renderingCache = Utils.getComponent((Type) RenderingCache.class); |
| 1090 |
|
} |
| 1091 |
12384 |
return this.renderingCache; |
| 1092 |
|
} |
| 1093 |
|
|
| 1094 |
|
|
| 1095 |
|
@return |
| 1096 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1097 |
25899 |
private DocumentDisplayer getDocumentDisplayer()... |
| 1098 |
|
{ |
| 1099 |
25901 |
if (this.documentDisplayer == null) { |
| 1100 |
9444 |
this.documentDisplayer = Utils.getComponent((Type) DocumentDisplayer.class, "configured"); |
| 1101 |
|
} |
| 1102 |
25898 |
return this.documentDisplayer; |
| 1103 |
|
} |
| 1104 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1105 |
16790 |
private Syntax getOutputSyntax()... |
| 1106 |
|
{ |
| 1107 |
16792 |
return getRenderingContext().getTargetSyntax(); |
| 1108 |
|
} |
| 1109 |
|
|
| 1110 |
|
|
| 1111 |
|
|
| 1112 |
|
|
| 1113 |
|
@param |
| 1114 |
|
@param@link |
| 1115 |
|
@param@link |
| 1116 |
|
@param |
| 1117 |
|
@link |
| 1118 |
|
@param |
| 1119 |
|
@return |
| 1120 |
|
@throws |
| 1121 |
|
|
| |
|
| 96.3% |
Uncovered Elements: 1 (27) |
Complexity: 3 |
Complexity Density: 0.13 |
|
| 1122 |
6194 |
private String display(Syntax targetSyntax, boolean executionContextIsolated, boolean transformationContextIsolated,... |
| 1123 |
|
boolean transformationContextRestricted, boolean translate) throws XWikiException |
| 1124 |
|
{ |
| 1125 |
|
|
| 1126 |
|
|
| 1127 |
|
|
| 1128 |
|
|
| 1129 |
|
|
| 1130 |
6194 |
getProgress().startStep(this, "document.progress.render", "Render document [{}] in syntax [{}]", |
| 1131 |
|
getDocumentReference(), targetSyntax); |
| 1132 |
|
|
| 1133 |
6194 |
try { |
| 1134 |
6193 |
getProgress().pushLevelProgress(3, getDocumentReference()); |
| 1135 |
|
|
| 1136 |
6194 |
getProgress().startStep(getDocumentReference(), "document.progress.render.translatedcontent", |
| 1137 |
|
"Get translated content"); |
| 1138 |
|
|
| 1139 |
6194 |
XWikiContext xcontext = getXWikiContext(); |
| 1140 |
|
|
| 1141 |
6194 |
XWikiDocument tdoc = translate ? getTranslatedDocument(xcontext) : this; |
| 1142 |
6194 |
String translatedContent = tdoc.getContent(); |
| 1143 |
|
|
| 1144 |
6194 |
getProgress().startStep(getDocumentReference(), "document.progress.render.cache", |
| 1145 |
|
"Try to get content from the cache"); |
| 1146 |
|
|
| 1147 |
6194 |
String renderedContent = getRenderingCache().getRenderedContent(tdoc.getDocumentReferenceWithLocale(), |
| 1148 |
|
translatedContent, xcontext); |
| 1149 |
|
|
| 1150 |
6193 |
if (renderedContent == null) { |
| 1151 |
6193 |
getProgress().startStep(getDocumentReference(), "document.progress.render.execute", "Execute content"); |
| 1152 |
|
|
| 1153 |
|
|
| 1154 |
6193 |
DocumentDisplayerParameters parameters = new DocumentDisplayerParameters(); |
| 1155 |
6193 |
parameters.setExecutionContextIsolated(executionContextIsolated); |
| 1156 |
6193 |
parameters.setTransformationContextIsolated(transformationContextIsolated); |
| 1157 |
6193 |
parameters.setTransformationContextRestricted(transformationContextRestricted); |
| 1158 |
|
|
| 1159 |
6194 |
parameters.setContentTranslated(tdoc != this); |
| 1160 |
6194 |
parameters.setTargetSyntax(targetSyntax); |
| 1161 |
|
|
| 1162 |
|
|
| 1163 |
6193 |
XDOM contentXDOM = getDocumentDisplayer().display(this, parameters); |
| 1164 |
|
|
| 1165 |
|
|
| 1166 |
6191 |
renderedContent = renderXDOM(contentXDOM, targetSyntax); |
| 1167 |
|
|
| 1168 |
6191 |
getRenderingCache().setRenderedContent(getDocumentReference(), translatedContent, renderedContent, |
| 1169 |
|
xcontext); |
| 1170 |
|
} |
| 1171 |
|
|
| 1172 |
6191 |
return renderedContent; |
| 1173 |
|
} finally { |
| 1174 |
6194 |
getProgress().popLevelProgress(getDocumentReference()); |
| 1175 |
6193 |
getProgress().endStep(this); |
| 1176 |
|
} |
| 1177 |
|
} |
| 1178 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1179 |
5808 |
public String getRenderedContent(Syntax targetSyntax, XWikiContext context) throws XWikiException... |
| 1180 |
|
{ |
| 1181 |
5808 |
return getRenderedContent(targetSyntax, true, context); |
| 1182 |
|
} |
| 1183 |
|
|
| 1184 |
|
|
| 1185 |
|
@since |
| 1186 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1187 |
0 |
public String getRenderedContent(boolean transformationContextIsolated, XWikiContext context) throws XWikiException... |
| 1188 |
|
{ |
| 1189 |
0 |
return getRenderedContent(getOutputSyntax(), transformationContextIsolated, context); |
| 1190 |
|
} |
| 1191 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 1192 |
5957 |
public String getRenderedContent(Syntax targetSyntax, boolean transformationContextIsolated, XWikiContext context)... |
| 1193 |
|
throws XWikiException |
| 1194 |
|
{ |
| 1195 |
|
|
| 1196 |
|
|
| 1197 |
5957 |
Object currrentSdoc = context.get("sdoc"); |
| 1198 |
5959 |
try { |
| 1199 |
|
|
| 1200 |
5959 |
XWikiDocument tdoc = getTranslatedDocument(context); |
| 1201 |
|
|
| 1202 |
5959 |
context.put("sdoc", tdoc); |
| 1203 |
|
|
| 1204 |
5959 |
return display(targetSyntax, false, transformationContextIsolated, false, true); |
| 1205 |
|
} finally { |
| 1206 |
5958 |
context.put("sdoc", currrentSdoc); |
| 1207 |
|
} |
| 1208 |
|
} |
| 1209 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1210 |
602 |
public String getRenderedContent(XWikiContext context) throws XWikiException... |
| 1211 |
|
{ |
| 1212 |
601 |
return getRenderedContent(getOutputSyntax(), context); |
| 1213 |
|
} |
| 1214 |
|
|
| 1215 |
|
|
| 1216 |
|
@param |
| 1217 |
|
@param |
| 1218 |
|
@param |
| 1219 |
|
@return |
| 1220 |
|
@since |
| 1221 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1222 |
200 |
public String getRenderedContent(String text, String syntaxId, XWikiContext context)... |
| 1223 |
|
{ |
| 1224 |
200 |
return getRenderedContent(text, syntaxId, getOutputSyntax().toIdString(), context); |
| 1225 |
|
} |
| 1226 |
|
|
| 1227 |
|
|
| 1228 |
|
@param |
| 1229 |
|
@param |
| 1230 |
|
@param@link |
| 1231 |
|
@param |
| 1232 |
|
@return |
| 1233 |
|
@since |
| 1234 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1235 |
0 |
public String getRenderedContent(String text, String syntaxId, boolean restrictedTransformationContext,... |
| 1236 |
|
XWikiContext context) |
| 1237 |
|
{ |
| 1238 |
0 |
return getRenderedContent(text, syntaxId, getOutputSyntax().toIdString(), restrictedTransformationContext, |
| 1239 |
|
context); |
| 1240 |
|
} |
| 1241 |
|
|
| 1242 |
|
|
| 1243 |
|
@param |
| 1244 |
|
@param |
| 1245 |
|
@param@link |
| 1246 |
|
@param@link |
| 1247 |
|
@param |
| 1248 |
|
@return |
| 1249 |
|
@since |
| 1250 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1251 |
31 |
public String getRenderedContent(String text, String syntaxId, boolean restrictedTransformationContext,... |
| 1252 |
|
XWikiDocument sDocument, XWikiContext context) |
| 1253 |
|
{ |
| 1254 |
31 |
return getRenderedContent(text, syntaxId, getOutputSyntax().toIdString(), restrictedTransformationContext, |
| 1255 |
|
sDocument, context); |
| 1256 |
|
} |
| 1257 |
|
|
| 1258 |
|
|
| 1259 |
|
@param |
| 1260 |
|
@param |
| 1261 |
|
@param |
| 1262 |
|
@param |
| 1263 |
|
@return |
| 1264 |
|
@since |
| 1265 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1266 |
200 |
public String getRenderedContent(String text, String sourceSyntaxId, String targetSyntaxId, XWikiContext context)... |
| 1267 |
|
{ |
| 1268 |
200 |
return getRenderedContent(text, sourceSyntaxId, targetSyntaxId, false, context); |
| 1269 |
|
} |
| 1270 |
|
|
| 1271 |
|
|
| 1272 |
|
@param |
| 1273 |
|
@param |
| 1274 |
|
@param |
| 1275 |
|
@param@link |
| 1276 |
|
@param |
| 1277 |
|
@return |
| 1278 |
|
@since |
| 1279 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1280 |
200 |
public String getRenderedContent(String text, String sourceSyntaxId, String targetSyntaxId,... |
| 1281 |
|
boolean restrictedTransformationContext, XWikiContext context) |
| 1282 |
|
{ |
| 1283 |
200 |
return getRenderedContent(text, sourceSyntaxId, targetSyntaxId, restrictedTransformationContext, null, context); |
| 1284 |
|
} |
| 1285 |
|
|
| 1286 |
|
|
| 1287 |
|
@param |
| 1288 |
|
@param |
| 1289 |
|
@param |
| 1290 |
|
@param@link |
| 1291 |
|
@param@link |
| 1292 |
|
@param |
| 1293 |
|
@return |
| 1294 |
|
@since |
| 1295 |
|
|
| |
|
| 92.9% |
Uncovered Elements: 2 (28) |
Complexity: 6 |
Complexity Density: 0.3 |
|
| 1296 |
235 |
public String getRenderedContent(String text, String sourceSyntaxId, String targetSyntaxId,... |
| 1297 |
|
boolean restrictedTransformationContext, XWikiDocument sDocument, XWikiContext context) |
| 1298 |
|
{ |
| 1299 |
235 |
Map<String, Object> backup = null; |
| 1300 |
|
|
| 1301 |
235 |
getProgress().startStep(this, "document.progress.renderText", |
| 1302 |
|
"Execute content [{}] in the context of document [{}]", |
| 1303 |
235 |
StringUtils.substring(text, 0, 100) + (text.length() >= 100 ? "..." : ""), getDocumentReference()); |
| 1304 |
|
|
| 1305 |
235 |
XWikiDocument currentSDocument = (XWikiDocument) context.get(CKEY_SDOC); |
| 1306 |
235 |
try { |
| 1307 |
|
|
| 1308 |
|
|
| 1309 |
|
|
| 1310 |
|
|
| 1311 |
235 |
if (context.getDoc() != this) { |
| 1312 |
34 |
backup = new HashMap<>(); |
| 1313 |
34 |
backupContext(backup, context); |
| 1314 |
34 |
setAsContextDoc(context); |
| 1315 |
|
} |
| 1316 |
|
|
| 1317 |
|
|
| 1318 |
235 |
if (sDocument != null) { |
| 1319 |
33 |
context.put(CKEY_SDOC, sDocument); |
| 1320 |
|
} |
| 1321 |
|
|
| 1322 |
|
|
| 1323 |
235 |
XWikiDocument fakeDocument = new XWikiDocument(getDocumentReference()); |
| 1324 |
235 |
fakeDocument.setSyntax(getSyntaxFactory().createSyntaxFromIdString(sourceSyntaxId)); |
| 1325 |
235 |
fakeDocument.setContent(text); |
| 1326 |
|
|
| 1327 |
|
|
| 1328 |
|
|
| 1329 |
235 |
return fakeDocument.display(getSyntaxFactory().createSyntaxFromIdString(targetSyntaxId), false, true, |
| 1330 |
|
restrictedTransformationContext, false); |
| 1331 |
|
} catch (Exception e) { |
| 1332 |
|
|
| 1333 |
|
|
| 1334 |
0 |
LOGGER.warn("Failed to render content [" + text + "]", e); |
| 1335 |
|
} finally { |
| 1336 |
235 |
if (backup != null) { |
| 1337 |
34 |
restoreContext(backup, context); |
| 1338 |
|
} |
| 1339 |
235 |
context.put(CKEY_SDOC, currentSDocument); |
| 1340 |
|
|
| 1341 |
235 |
getProgress().endStep(this); |
| 1342 |
|
} |
| 1343 |
|
|
| 1344 |
0 |
return ""; |
| 1345 |
|
} |
| 1346 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1347 |
0 |
public String getEscapedContent(XWikiContext context) throws XWikiException... |
| 1348 |
|
{ |
| 1349 |
0 |
return XMLUtils.escape(getTranslatedContent(context)); |
| 1350 |
|
} |
| 1351 |
|
|
| 1352 |
|
|
| 1353 |
|
|
| 1354 |
|
|
| 1355 |
|
@deprecated@link |
| 1356 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1357 |
70224 |
@Deprecated... |
| 1358 |
|
public String getName() |
| 1359 |
|
{ |
| 1360 |
70217 |
return getDocumentReference().getName(); |
| 1361 |
|
} |
| 1362 |
|
|
| 1363 |
|
|
| 1364 |
|
|
| 1365 |
|
|
| 1366 |
|
@deprecated@link |
| 1367 |
|
|
| |
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1368 |
3644 |
@Deprecated... |
| 1369 |
|
public void setName(String name) |
| 1370 |
|
{ |
| 1371 |
3643 |
if (name != null) { |
| 1372 |
3643 |
DocumentReference reference = getDocumentReference(); |
| 1373 |
|
|
| 1374 |
3644 |
setDocumentReferenceInternal( |
| 1375 |
|
new DocumentReference(name, new SpaceReference(reference.getParent()), reference.getLocale())); |
| 1376 |
|
} |
| 1377 |
|
} |
| 1378 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1379 |
11749297 |
@Override... |
| 1380 |
|
public DocumentReference getDocumentReference() |
| 1381 |
|
{ |
| 1382 |
11749302 |
return this.documentReference; |
| 1383 |
|
} |
| 1384 |
|
|
| 1385 |
|
|
| 1386 |
|
@return@link@link |
| 1387 |
|
@since |
| 1388 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1389 |
668991 |
public DocumentReference getDocumentReferenceWithLocale()... |
| 1390 |
|
{ |
| 1391 |
669007 |
return new DocumentReference(this.documentReference, getLocale()); |
| 1392 |
|
} |
| 1393 |
|
|
| 1394 |
|
|
| 1395 |
|
@return |
| 1396 |
|
@deprecated@link |
| 1397 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1398 |
155822 |
@Deprecated... |
| 1399 |
|
@Override |
| 1400 |
|
public String getFullName() |
| 1401 |
|
{ |
| 1402 |
155815 |
return LOCAL_REFERENCE_SERIALIZER.serialize(getDocumentReference()); |
| 1403 |
|
} |
| 1404 |
|
|
| 1405 |
|
|
| 1406 |
|
@return |
| 1407 |
|
@deprecated@link |
| 1408 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1409 |
48892 |
@Deprecated... |
| 1410 |
|
public String getPrefixedFullName() |
| 1411 |
|
{ |
| 1412 |
48891 |
return getDefaultEntityReferenceSerializer().serialize(getDocumentReference()); |
| 1413 |
|
} |
| 1414 |
|
|
| 1415 |
|
|
| 1416 |
|
@since |
| 1417 |
|
@deprecated |
| 1418 |
|
|
| 1419 |
|
|
| |
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 4 |
Complexity Density: 1 |
|
| 1420 |
1338319 |
@Deprecated... |
| 1421 |
|
public void setDocumentReference(DocumentReference reference) |
| 1422 |
|
{ |
| 1423 |
|
|
| 1424 |
|
|
| 1425 |
1338312 |
if (reference != null) { |
| 1426 |
|
|
| 1427 |
1338309 |
DocumentReference referenceWithoutLocale = |
| 1428 |
1338297 |
reference.getLocale() != null ? new DocumentReference(reference, null) : reference; |
| 1429 |
|
|
| 1430 |
1338318 |
if (!referenceWithoutLocale.equals(getDocumentReference())) { |
| 1431 |
1329586 |
setDocumentReferenceInternal(referenceWithoutLocale); |
| 1432 |
|
} |
| 1433 |
|
} |
| 1434 |
|
} |
| 1435 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 1436 |
1340455 |
private void setDocumentReferenceInternal(DocumentReference reference)... |
| 1437 |
|
{ |
| 1438 |
1340487 |
this.documentReference = reference; |
| 1439 |
|
|
| 1440 |
1340477 |
setMetaDataDirty(true); |
| 1441 |
|
|
| 1442 |
|
|
| 1443 |
|
|
| 1444 |
1340495 |
this.keyCache = null; |
| 1445 |
1340488 |
this.localKeyCache = null; |
| 1446 |
1340499 |
this.parentReferenceCache = null; |
| 1447 |
|
} |
| 1448 |
|
|
| 1449 |
|
|
| 1450 |
|
@deprecated@link |
| 1451 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1452 |
3712 |
@Deprecated... |
| 1453 |
|
public void setFullName(String name) |
| 1454 |
|
{ |
| 1455 |
3712 |
setFullName(name, null); |
| 1456 |
|
} |
| 1457 |
|
|
| 1458 |
|
|
| 1459 |
|
@deprecated@link |
| 1460 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 1461 |
23387 |
@Deprecated... |
| 1462 |
|
public void setFullName(String fullName, XWikiContext context) |
| 1463 |
|
{ |
| 1464 |
|
|
| 1465 |
|
|
| 1466 |
23400 |
if (fullName != null) { |
| 1467 |
|
|
| 1468 |
|
|
| 1469 |
23405 |
setDocumentReference(getCurrentMixedDocumentReferenceResolver().resolve(fullName)); |
| 1470 |
|
} |
| 1471 |
|
} |
| 1472 |
|
|
| 1473 |
|
|
| 1474 |
|
@inheritDoc |
| 1475 |
|
|
| 1476 |
|
@see |
| 1477 |
|
@deprecated@link |
| 1478 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1479 |
464 |
@Deprecated... |
| 1480 |
|
@Override |
| 1481 |
|
public String getWikiName() |
| 1482 |
|
{ |
| 1483 |
464 |
return getDatabase(); |
| 1484 |
|
} |
| 1485 |
|
|
| 1486 |
|
|
| 1487 |
|
@inheritDoc |
| 1488 |
|
|
| 1489 |
|
@see |
| 1490 |
|
@deprecated@link |
| 1491 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1492 |
7 |
@Deprecated... |
| 1493 |
|
@Override |
| 1494 |
|
public String getSpaceName() |
| 1495 |
|
{ |
| 1496 |
7 |
return this.getSpace(); |
| 1497 |
|
} |
| 1498 |
|
|
| 1499 |
|
|
| 1500 |
|
@inheritDoc |
| 1501 |
|
|
| 1502 |
|
@see |
| 1503 |
|
@deprecated@link |
| 1504 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1505 |
8 |
@Deprecated... |
| 1506 |
|
@Override |
| 1507 |
|
public String getPageName() |
| 1508 |
|
{ |
| 1509 |
8 |
return this.getName(); |
| 1510 |
|
} |
| 1511 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 1512 |
70435 |
@Override... |
| 1513 |
|
public String getTitle() |
| 1514 |
|
{ |
| 1515 |
70430 |
return (this.title != null) ? this.title : ""; |
| 1516 |
|
} |
| 1517 |
|
|
| 1518 |
|
|
| 1519 |
|
|
| 1520 |
|
|
| 1521 |
|
|
| 1522 |
|
|
| 1523 |
|
|
| 1524 |
|
|
| 1525 |
|
|
| 1526 |
|
|
| 1527 |
|
|
| 1528 |
|
|
| 1529 |
|
|
| 1530 |
|
|
| 1531 |
|
@param |
| 1532 |
|
@param |
| 1533 |
|
@return |
| 1534 |
|
|
| |
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 2 |
Complexity Density: 0.22 |
|
| 1535 |
19706 |
public String getRenderedTitle(Syntax outputSyntax, XWikiContext context)... |
| 1536 |
|
{ |
| 1537 |
19707 |
DocumentDisplayerParameters parameters = new DocumentDisplayerParameters(); |
| 1538 |
19705 |
parameters.setTitleDisplayed(true); |
| 1539 |
19705 |
parameters.setExecutionContextIsolated(true); |
| 1540 |
19706 |
parameters.setTargetSyntax(outputSyntax); |
| 1541 |
19705 |
try { |
| 1542 |
19706 |
XDOM titleXDOM = getDocumentDisplayer().display(this, parameters); |
| 1543 |
19706 |
return renderXDOM(titleXDOM, outputSyntax); |
| 1544 |
|
} catch (Exception e) { |
| 1545 |
|
|
| 1546 |
|
|
| 1547 |
|
|
| 1548 |
0 |
LOGGER.error("Failed to render title for [{}]", getDocumentReference(), e); |
| 1549 |
0 |
return getDocumentReference().getName(); |
| 1550 |
|
} |
| 1551 |
|
} |
| 1552 |
|
|
| 1553 |
|
|
| 1554 |
|
@link |
| 1555 |
|
|
| 1556 |
|
|
| 1557 |
|
@param |
| 1558 |
|
@return |
| 1559 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1560 |
15959 |
public String getRenderedTitle(XWikiContext context)... |
| 1561 |
|
{ |
| 1562 |
15958 |
return getRenderedTitle(getOutputSyntax(), context); |
| 1563 |
|
} |
| 1564 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 1565 |
43952 |
public void setTitle(String title)... |
| 1566 |
|
{ |
| 1567 |
43949 |
if (title != null && !title.equals(this.title)) { |
| 1568 |
|
|
| 1569 |
|
|
| 1570 |
38639 |
setContentDirty(true); |
| 1571 |
|
} |
| 1572 |
43948 |
this.title = title; |
| 1573 |
|
} |
| 1574 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 1575 |
31541 |
public String getFormat()... |
| 1576 |
|
{ |
| 1577 |
31540 |
return this.format != null ? this.format : ""; |
| 1578 |
|
} |
| 1579 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1580 |
31328 |
public void setFormat(String format)... |
| 1581 |
|
{ |
| 1582 |
31326 |
this.format = format; |
| 1583 |
31327 |
if (!format.equals(this.format)) { |
| 1584 |
0 |
setMetaDataDirty(true); |
| 1585 |
|
} |
| 1586 |
|
} |
| 1587 |
|
|
| 1588 |
|
|
| 1589 |
|
@param@link@link |
| 1590 |
|
@return@link |
| 1591 |
|
|
| |
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 1592 |
12256 |
private DocumentReference userStringToReference(String userString)... |
| 1593 |
|
{ |
| 1594 |
12258 |
DocumentReference userReference; |
| 1595 |
|
|
| 1596 |
12260 |
if (StringUtils.isEmpty(userString)) { |
| 1597 |
0 |
userReference = null; |
| 1598 |
|
} else { |
| 1599 |
12260 |
userReference = getExplicitReferenceDocumentReferenceResolver().resolve( |
| 1600 |
|
getXClassEntityReferenceResolver().resolve(userString, EntityType.DOCUMENT), getDocumentReference()); |
| 1601 |
|
|
| 1602 |
12260 |
if (userReference.getName().equals(XWikiRightService.GUEST_USER)) { |
| 1603 |
95 |
userReference = null; |
| 1604 |
|
} |
| 1605 |
|
} |
| 1606 |
|
|
| 1607 |
12260 |
return userReference; |
| 1608 |
|
} |
| 1609 |
|
|
| 1610 |
|
|
| 1611 |
|
@param@link@link |
| 1612 |
|
@return |
| 1613 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 1614 |
51257 |
private String userReferenceToString(DocumentReference userReference)... |
| 1615 |
|
{ |
| 1616 |
51257 |
String userString; |
| 1617 |
|
|
| 1618 |
51257 |
if (userReference != null) { |
| 1619 |
50648 |
userString = getCompactWikiEntityReferenceSerializer().serialize(userReference, getDocumentReference()); |
| 1620 |
|
} else { |
| 1621 |
609 |
userString = XWikiRightService.GUEST_USER_FULLNAME; |
| 1622 |
|
} |
| 1623 |
|
|
| 1624 |
51257 |
return userString; |
| 1625 |
|
} |
| 1626 |
|
|
| 1627 |
|
|
| 1628 |
|
@since |
| 1629 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1630 |
191543 |
public DocumentReference getAuthorReference()... |
| 1631 |
|
{ |
| 1632 |
191542 |
return this.authorReference; |
| 1633 |
|
} |
| 1634 |
|
|
| 1635 |
|
|
| 1636 |
|
@since |
| 1637 |
|
|
| |
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 1638 |
129604 |
public void setAuthorReference(DocumentReference authorReference)... |
| 1639 |
|
{ |
| 1640 |
129599 |
if (ObjectUtils.notEqual(authorReference, getAuthorReference())) { |
| 1641 |
112592 |
setMetaDataDirty(true); |
| 1642 |
|
} |
| 1643 |
|
|
| 1644 |
129596 |
this.authorReference = authorReference; |
| 1645 |
|
|
| 1646 |
|
|
| 1647 |
129607 |
if (this.authorReference != null && this.authorReference.getName().equals(XWikiRightService.GUEST_USER)) { |
| 1648 |
0 |
LOGGER.warn("A reference to XWikiGuest user has been set instead of null. This is probably a mistake.", |
| 1649 |
|
new Exception("See stack trace")); |
| 1650 |
|
} |
| 1651 |
|
} |
| 1652 |
|
|
| 1653 |
|
|
| 1654 |
|
|
| 1655 |
|
|
| 1656 |
|
@deprecated@link |
| 1657 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1658 |
21306 |
@Deprecated... |
| 1659 |
|
public String getAuthor() |
| 1660 |
|
{ |
| 1661 |
21306 |
return userReferenceToString(getAuthorReference()); |
| 1662 |
|
} |
| 1663 |
|
|
| 1664 |
|
|
| 1665 |
|
|
| 1666 |
|
|
| 1667 |
|
@deprecated@link |
| 1668 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1669 |
3875 |
@Deprecated... |
| 1670 |
|
public void setAuthor(String author) |
| 1671 |
|
{ |
| 1672 |
3876 |
setAuthorReference(userStringToReference(author)); |
| 1673 |
|
} |
| 1674 |
|
|
| 1675 |
|
|
| 1676 |
|
@since |
| 1677 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1678 |
201045 |
@Override... |
| 1679 |
|
public DocumentReference getContentAuthorReference() |
| 1680 |
|
{ |
| 1681 |
201050 |
return this.contentAuthorReference; |
| 1682 |
|
} |
| 1683 |
|
|
| 1684 |
|
|
| 1685 |
|
@since |
| 1686 |
|
|
| |
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 1687 |
129303 |
public void setContentAuthorReference(DocumentReference contentAuthorReference)... |
| 1688 |
|
{ |
| 1689 |
129308 |
if (ObjectUtils.notEqual(contentAuthorReference, getContentAuthorReference())) { |
| 1690 |
112541 |
setMetaDataDirty(true); |
| 1691 |
|
} |
| 1692 |
|
|
| 1693 |
129287 |
this.contentAuthorReference = contentAuthorReference; |
| 1694 |
|
|
| 1695 |
|
|
| 1696 |
129305 |
if (this.contentAuthorReference != null |
| 1697 |
|
&& this.contentAuthorReference.getName().equals(XWikiRightService.GUEST_USER)) { |
| 1698 |
0 |
LOGGER.warn("A reference to XWikiGuest user has been set instead of null. This is probably a mistake.", |
| 1699 |
|
new Exception("See stack trace")); |
| 1700 |
|
} |
| 1701 |
|
} |
| 1702 |
|
|
| 1703 |
|
|
| 1704 |
|
|
| 1705 |
|
|
| 1706 |
|
@deprecated@link |
| 1707 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1708 |
14810 |
@Deprecated... |
| 1709 |
|
public String getContentAuthor() |
| 1710 |
|
{ |
| 1711 |
14810 |
return userReferenceToString(getContentAuthorReference()); |
| 1712 |
|
} |
| 1713 |
|
|
| 1714 |
|
|
| 1715 |
|
|
| 1716 |
|
|
| 1717 |
|
@deprecated@link |
| 1718 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1719 |
3644 |
@Deprecated... |
| 1720 |
|
public void setContentAuthor(String contentAuthor) |
| 1721 |
|
{ |
| 1722 |
3643 |
setContentAuthorReference(userStringToReference(contentAuthor)); |
| 1723 |
|
} |
| 1724 |
|
|
| 1725 |
|
|
| 1726 |
|
@since |
| 1727 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1728 |
178823 |
public DocumentReference getCreatorReference()... |
| 1729 |
|
{ |
| 1730 |
178833 |
return this.creatorReference; |
| 1731 |
|
} |
| 1732 |
|
|
| 1733 |
|
|
| 1734 |
|
@since |
| 1735 |
|
|
| |
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 1736 |
126431 |
public void setCreatorReference(DocumentReference creatorReference)... |
| 1737 |
|
{ |
| 1738 |
126434 |
if (ObjectUtils.notEqual(creatorReference, getCreatorReference())) { |
| 1739 |
110414 |
setMetaDataDirty(true); |
| 1740 |
|
} |
| 1741 |
|
|
| 1742 |
126433 |
this.creatorReference = creatorReference; |
| 1743 |
|
|
| 1744 |
|
|
| 1745 |
126437 |
if (this.creatorReference != null && this.creatorReference.getName().equals(XWikiRightService.GUEST_USER)) { |
| 1746 |
0 |
LOGGER.warn("A reference to XWikiGuest user has been set instead of null. This is probably a mistake.", |
| 1747 |
|
new Exception("See stack trace")); |
| 1748 |
|
} |
| 1749 |
|
} |
| 1750 |
|
|
| 1751 |
|
|
| 1752 |
|
|
| 1753 |
|
|
| 1754 |
|
@deprecated@link |
| 1755 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1756 |
15141 |
@Deprecated... |
| 1757 |
|
public String getCreator() |
| 1758 |
|
{ |
| 1759 |
15141 |
return userReferenceToString(getCreatorReference()); |
| 1760 |
|
} |
| 1761 |
|
|
| 1762 |
|
|
| 1763 |
|
|
| 1764 |
|
|
| 1765 |
|
@deprecated@link |
| 1766 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1767 |
4739 |
@Deprecated... |
| 1768 |
|
public void setCreator(String creator) |
| 1769 |
|
{ |
| 1770 |
4740 |
setCreatorReference(userStringToReference(creator)); |
| 1771 |
|
} |
| 1772 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1773 |
56626 |
public Date getDate()... |
| 1774 |
|
{ |
| 1775 |
56629 |
if (this.updateDate == null) { |
| 1776 |
0 |
return new Date(); |
| 1777 |
|
} else { |
| 1778 |
56631 |
return this.updateDate; |
| 1779 |
|
} |
| 1780 |
|
} |
| 1781 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 1782 |
50372 |
public void setDate(Date date)... |
| 1783 |
|
{ |
| 1784 |
50380 |
if ((date != null) && (!date.equals(this.updateDate))) { |
| 1785 |
31667 |
setMetaDataDirty(true); |
| 1786 |
|
} |
| 1787 |
|
|
| 1788 |
50377 |
if (date != null) { |
| 1789 |
50376 |
date.setTime((date.getTime() / 1000) * 1000); |
| 1790 |
|
} |
| 1791 |
50376 |
this.updateDate = date; |
| 1792 |
|
} |
| 1793 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1794 |
51027 |
public Date getCreationDate()... |
| 1795 |
|
{ |
| 1796 |
51031 |
if (this.creationDate == null) { |
| 1797 |
23 |
return new Date(); |
| 1798 |
|
} else { |
| 1799 |
51008 |
return this.creationDate; |
| 1800 |
|
} |
| 1801 |
|
} |
| 1802 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 1803 |
46207 |
public void setCreationDate(Date date)... |
| 1804 |
|
{ |
| 1805 |
46216 |
if ((date != null) && (!date.equals(this.creationDate))) { |
| 1806 |
25207 |
setMetaDataDirty(true); |
| 1807 |
|
} |
| 1808 |
|
|
| 1809 |
|
|
| 1810 |
46213 |
if (date != null) { |
| 1811 |
43606 |
date.setTime((date.getTime() / 1000) * 1000); |
| 1812 |
|
} |
| 1813 |
46212 |
this.creationDate = date; |
| 1814 |
|
} |
| 1815 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1816 |
50574 |
public Date getContentUpdateDate()... |
| 1817 |
|
{ |
| 1818 |
50575 |
if (this.contentUpdateDate == null) { |
| 1819 |
0 |
return new Date(); |
| 1820 |
|
} else { |
| 1821 |
50574 |
return this.contentUpdateDate; |
| 1822 |
|
} |
| 1823 |
|
} |
| 1824 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 1825 |
50008 |
public void setContentUpdateDate(Date date)... |
| 1826 |
|
{ |
| 1827 |
50009 |
if ((date != null) && (!date.equals(this.contentUpdateDate))) { |
| 1828 |
30482 |
setMetaDataDirty(true); |
| 1829 |
|
} |
| 1830 |
|
|
| 1831 |
|
|
| 1832 |
50013 |
if (date != null) { |
| 1833 |
50010 |
date.setTime((date.getTime() / 1000) * 1000); |
| 1834 |
|
} |
| 1835 |
50011 |
this.contentUpdateDate = date; |
| 1836 |
|
} |
| 1837 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1838 |
31323 |
public String getMeta()... |
| 1839 |
|
{ |
| 1840 |
31327 |
return this.meta; |
| 1841 |
|
} |
| 1842 |
|
|
| |
|
| 41.7% |
Uncovered Elements: 7 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 1843 |
31326 |
public void setMeta(String meta)... |
| 1844 |
|
{ |
| 1845 |
31324 |
if (meta == null) { |
| 1846 |
31328 |
if (this.meta != null) { |
| 1847 |
0 |
setMetaDataDirty(true); |
| 1848 |
|
} |
| 1849 |
0 |
} else if (!meta.equals(this.meta)) { |
| 1850 |
0 |
setMetaDataDirty(true); |
| 1851 |
|
} |
| 1852 |
31328 |
this.meta = meta; |
| 1853 |
|
} |
| 1854 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 1855 |
0 |
public void appendMeta(String meta)... |
| 1856 |
|
{ |
| 1857 |
0 |
StringBuilder buf = new StringBuilder(this.meta); |
| 1858 |
0 |
buf.append(meta); |
| 1859 |
0 |
buf.append("\n"); |
| 1860 |
0 |
this.meta = buf.toString(); |
| 1861 |
0 |
setMetaDataDirty(true); |
| 1862 |
|
} |
| 1863 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1864 |
41233 |
public boolean isContentDirty()... |
| 1865 |
|
{ |
| 1866 |
41229 |
return this.isContentDirty; |
| 1867 |
|
} |
| 1868 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 1869 |
2200 |
public void incrementVersion()... |
| 1870 |
|
{ |
| 1871 |
2200 |
if (this.version == null) { |
| 1872 |
1763 |
this.version = new Version("1.1"); |
| 1873 |
|
} else { |
| 1874 |
437 |
if (isMinorEdit()) { |
| 1875 |
72 |
this.version = this.version.next(); |
| 1876 |
|
} else { |
| 1877 |
365 |
this.version = this.version.getBranchPoint().next().newBranch(1); |
| 1878 |
|
} |
| 1879 |
|
} |
| 1880 |
|
} |
| 1881 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1882 |
658476 |
public void setContentDirty(boolean contentDirty)... |
| 1883 |
|
{ |
| 1884 |
658475 |
this.isContentDirty = contentDirty; |
| 1885 |
|
} |
| 1886 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1887 |
37223 |
public boolean isMetaDataDirty()... |
| 1888 |
|
{ |
| 1889 |
37225 |
return this.isMetaDataDirty; |
| 1890 |
|
} |
| 1891 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1892 |
5978428 |
public void setMetaDataDirty(boolean metaDataDirty)... |
| 1893 |
|
{ |
| 1894 |
5978037 |
this.isMetaDataDirty = metaDataDirty; |
| 1895 |
|
} |
| 1896 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1897 |
9 |
public String getAttachmentURL(String filename, XWikiContext context)... |
| 1898 |
|
{ |
| 1899 |
9 |
return getAttachmentURL(filename, "download", context); |
| 1900 |
|
} |
| 1901 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1902 |
12 |
public String getAttachmentURL(String filename, String action, XWikiContext context)... |
| 1903 |
|
{ |
| 1904 |
12 |
return getAttachmentURL(filename, action, null, context); |
| 1905 |
|
} |
| 1906 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1907 |
0 |
public String getExternalAttachmentURL(String filename, String action, XWikiContext context)... |
| 1908 |
|
{ |
| 1909 |
0 |
URL url = context.getURLFactory().createAttachmentURL(filename, getSpace(), getName(), action, null, |
| 1910 |
|
getDatabase(), context); |
| 1911 |
0 |
return url.toString(); |
| 1912 |
|
} |
| 1913 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1914 |
36 |
public String getAttachmentURL(String filename, String action, String querystring, XWikiContext context)... |
| 1915 |
|
{ |
| 1916 |
|
|
| 1917 |
36 |
if (StringUtils.isEmpty(filename)) { |
| 1918 |
0 |
return null; |
| 1919 |
|
} |
| 1920 |
|
|
| 1921 |
36 |
return context.getWiki().getAttachmentURL(new AttachmentReference(filename, this.getDocumentReference()), |
| 1922 |
|
action, querystring, context); |
| 1923 |
|
} |
| 1924 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1925 |
0 |
public String getAttachmentRevisionURL(String filename, String revision, XWikiContext context)... |
| 1926 |
|
{ |
| 1927 |
0 |
return getAttachmentRevisionURL(filename, revision, null, context); |
| 1928 |
|
} |
| 1929 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1930 |
0 |
public String getAttachmentRevisionURL(String filename, String revision, String querystring, XWikiContext context)... |
| 1931 |
|
{ |
| 1932 |
|
|
| 1933 |
0 |
if (StringUtils.isEmpty(filename)) { |
| 1934 |
0 |
return null; |
| 1935 |
|
} |
| 1936 |
|
|
| 1937 |
0 |
return context.getWiki().getAttachmentRevisionURL(new AttachmentReference(filename, getDocumentReference()), |
| 1938 |
|
revision, querystring, context); |
| 1939 |
|
} |
| 1940 |
|
|
| 1941 |
|
|
| 1942 |
|
@param |
| 1943 |
|
@param |
| 1944 |
|
@param@link |
| 1945 |
|
@param |
| 1946 |
|
@return |
| 1947 |
|
|
| |
|
| 40% |
Uncovered Elements: 6 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 1948 |
34776 |
public String getURL(String action, String params, boolean redirect, XWikiContext context)... |
| 1949 |
|
{ |
| 1950 |
34777 |
URL url = |
| 1951 |
|
context.getURLFactory().createURL(getSpace(), getName(), action, params, null, getDatabase(), context); |
| 1952 |
|
|
| 1953 |
34778 |
if (redirect && isRedirectAbsolute(context)) { |
| 1954 |
0 |
if (url == null) { |
| 1955 |
0 |
return null; |
| 1956 |
|
} else { |
| 1957 |
0 |
return url.toString(); |
| 1958 |
|
} |
| 1959 |
|
} else { |
| 1960 |
34775 |
return context.getURLFactory().getURL(url, context); |
| 1961 |
|
} |
| 1962 |
|
} |
| 1963 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1964 |
163 |
private boolean isRedirectAbsolute(XWikiContext context)... |
| 1965 |
|
{ |
| 1966 |
163 |
return StringUtils.equals("1", context.getWiki().Param("xwiki.redirect.absoluteurl")); |
| 1967 |
|
} |
| 1968 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1969 |
34613 |
public String getURL(String action, boolean redirect, XWikiContext context)... |
| 1970 |
|
{ |
| 1971 |
34614 |
return getURL(action, null, redirect, context); |
| 1972 |
|
} |
| 1973 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1974 |
34616 |
public String getURL(String action, XWikiContext context)... |
| 1975 |
|
{ |
| 1976 |
34616 |
return getURL(action, false, context); |
| 1977 |
|
} |
| 1978 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1979 |
13537 |
public String getURL(String action, String querystring, XWikiContext context)... |
| 1980 |
|
{ |
| 1981 |
13538 |
URL url = |
| 1982 |
|
context.getURLFactory().createURL(getSpace(), getName(), action, querystring, null, getDatabase(), context); |
| 1983 |
13538 |
return context.getURLFactory().getURL(url, context); |
| 1984 |
|
} |
| 1985 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1986 |
0 |
public String getURL(String action, String querystring, String anchor, XWikiContext context)... |
| 1987 |
|
{ |
| 1988 |
0 |
URL url = context.getURLFactory().createURL(getSpace(), getName(), action, querystring, anchor, getDatabase(), |
| 1989 |
|
context); |
| 1990 |
0 |
return context.getURLFactory().getURL(url, context); |
| 1991 |
|
} |
| 1992 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1993 |
640 |
public String getExternalURL(String action, XWikiContext context)... |
| 1994 |
|
{ |
| 1995 |
640 |
URL url = context.getURLFactory().createExternalURL(getSpace(), getName(), action, null, null, getDatabase(), |
| 1996 |
|
context); |
| 1997 |
640 |
return url.toString(); |
| 1998 |
|
} |
| 1999 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 2000 |
25 |
public String getExternalURL(String action, String querystring, XWikiContext context)... |
| 2001 |
|
{ |
| 2002 |
25 |
URL url = context.getURLFactory().createExternalURL(getSpace(), getName(), action, querystring, null, |
| 2003 |
|
getDatabase(), context); |
| 2004 |
25 |
return url.toString(); |
| 2005 |
|
} |
| 2006 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 2007 |
0 |
public String getParentURL(XWikiContext context) throws XWikiException... |
| 2008 |
|
{ |
| 2009 |
0 |
XWikiDocument doc = new XWikiDocument(getParentReference()); |
| 2010 |
0 |
URL url = context.getURLFactory().createURL(doc.getSpace(), doc.getName(), "view", null, null, getDatabase(), |
| 2011 |
|
context); |
| 2012 |
0 |
return context.getURLFactory().getURL(url, context); |
| 2013 |
|
} |
| 2014 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 2015 |
2221 |
public XWikiDocumentArchive getDocumentArchive(XWikiContext context) throws XWikiException... |
| 2016 |
|
{ |
| 2017 |
2221 |
loadArchive(context); |
| 2018 |
2221 |
return getDocumentArchive(); |
| 2019 |
|
} |
| 2020 |
|
|
| 2021 |
|
|
| 2022 |
|
@link |
| 2023 |
|
|
| 2024 |
|
|
| 2025 |
|
@param@link |
| 2026 |
|
@param |
| 2027 |
|
@return |
| 2028 |
|
|
| 2029 |
|
|
| |
|
| 42.9% |
Uncovered Elements: 4 (7) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 2030 |
193316 |
public com.xpn.xwiki.api.Document newDocument(String customClassName, XWikiContext context)... |
| 2031 |
|
{ |
| 2032 |
193310 |
if (!((customClassName == null) || (customClassName.equals("")))) { |
| 2033 |
0 |
try { |
| 2034 |
0 |
return newDocument(Class.forName(customClassName), context); |
| 2035 |
|
} catch (ClassNotFoundException e) { |
| 2036 |
0 |
LOGGER.error("Failed to get java Class object from class name", e); |
| 2037 |
|
} |
| 2038 |
|
} |
| 2039 |
|
|
| 2040 |
193289 |
return new com.xpn.xwiki.api.Document(this, context); |
| 2041 |
|
} |
| 2042 |
|
|
| 2043 |
|
|
| 2044 |
|
@link |
| 2045 |
|
|
| 2046 |
|
|
| 2047 |
|
@param@link |
| 2048 |
|
@param |
| 2049 |
|
@return |
| 2050 |
|
|
| 2051 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 2052 |
0 |
public com.xpn.xwiki.api.Document newDocument(Class<?> customClass, XWikiContext context)... |
| 2053 |
|
{ |
| 2054 |
0 |
if (customClass != null) { |
| 2055 |
0 |
try { |
| 2056 |
0 |
Class<?>[] classes = new Class[] { XWikiDocument.class, XWikiContext.class }; |
| 2057 |
0 |
Object[] args = new Object[] { this, context }; |
| 2058 |
|
|
| 2059 |
0 |
return (com.xpn.xwiki.api.Document) customClass.getConstructor(classes).newInstance(args); |
| 2060 |
|
} catch (Exception e) { |
| 2061 |
0 |
LOGGER.error("Failed to create a custom Document object", e); |
| 2062 |
|
} |
| 2063 |
|
} |
| 2064 |
|
|
| 2065 |
0 |
return new com.xpn.xwiki.api.Document(this, context); |
| 2066 |
|
} |
| 2067 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 2068 |
193314 |
public com.xpn.xwiki.api.Document newDocument(XWikiContext context)... |
| 2069 |
|
{ |
| 2070 |
193307 |
String customClass = getCustomClass(); |
| 2071 |
193311 |
return newDocument(customClass, context); |
| 2072 |
|
} |
| 2073 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 2074 |
2347 |
public void loadArchive(XWikiContext context) throws XWikiException... |
| 2075 |
|
{ |
| 2076 |
2347 |
if (this.archive == null || this.archive.get() == null) { |
| 2077 |
2304 |
XWikiDocumentArchive arch = getVersioningStore(context).getXWikiDocumentArchive(this, context); |
| 2078 |
|
|
| 2079 |
|
|
| 2080 |
|
|
| 2081 |
2304 |
this.archive = new SoftReference<XWikiDocumentArchive>(arch); |
| 2082 |
|
} |
| 2083 |
|
} |
| 2084 |
|
|
| 2085 |
|
|
| 2086 |
|
@return@link |
| 2087 |
|
|
| 2088 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 2089 |
50129 |
public XWikiDocumentArchive getDocumentArchive()... |
| 2090 |
|
{ |
| 2091 |
|
|
| 2092 |
50130 |
if (this.archive != null) { |
| 2093 |
15145 |
return this.archive.get(); |
| 2094 |
|
} |
| 2095 |
34981 |
return null; |
| 2096 |
|
} |
| 2097 |
|
|
| 2098 |
|
|
| 2099 |
|
@return@link |
| 2100 |
|
|
| 2101 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 2102 |
7 |
public XWikiDocumentArchive loadDocumentArchive()... |
| 2103 |
|
{ |
| 2104 |
7 |
XWikiDocumentArchive arch = getDocumentArchive(); |
| 2105 |
7 |
if (arch != null) { |
| 2106 |
6 |
return arch; |
| 2107 |
|
} |
| 2108 |
|
|
| 2109 |
1 |
XWikiContext xcontext = getXWikiContext(); |
| 2110 |
|
|
| 2111 |
1 |
try { |
| 2112 |
1 |
arch = getVersioningStore(xcontext).getXWikiDocumentArchive(this, xcontext); |
| 2113 |
|
|
| 2114 |
|
|
| 2115 |
1 |
setDocumentArchive(arch); |
| 2116 |
|
|
| 2117 |
1 |
return arch; |
| 2118 |
|
} catch (Exception e) { |
| 2119 |
|
|
| 2120 |
|
|
| 2121 |
|
|
| 2122 |
|
|
| 2123 |
0 |
LOGGER.warn("Could not get document archive", e); |
| 2124 |
0 |
return null; |
| 2125 |
|
} |
| 2126 |
|
} |
| 2127 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 2128 |
35417 |
public void setDocumentArchive(XWikiDocumentArchive arch)... |
| 2129 |
|
{ |
| 2130 |
|
|
| 2131 |
|
|
| 2132 |
|
|
| 2133 |
35417 |
if (arch != null) { |
| 2134 |
8412 |
this.archive = new SoftReference<XWikiDocumentArchive>(arch); |
| 2135 |
|
} |
| 2136 |
|
} |
| 2137 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 2138 |
8 |
public void setDocumentArchive(String sarch) throws XWikiException... |
| 2139 |
|
{ |
| 2140 |
8 |
XWikiDocumentArchive xda = new XWikiDocumentArchive(getId()); |
| 2141 |
8 |
xda.setArchive(sarch); |
| 2142 |
8 |
setDocumentArchive(xda); |
| 2143 |
|
} |
| 2144 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2145 |
2127 |
public Version[] getRevisions(XWikiContext context) throws XWikiException... |
| 2146 |
|
{ |
| 2147 |
2127 |
return getVersioningStore(context).getXWikiDocVersions(this, context); |
| 2148 |
|
} |
| 2149 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.42 |
|
| 2150 |
0 |
public String[] getRecentRevisions(int nb, XWikiContext context) throws XWikiException... |
| 2151 |
|
{ |
| 2152 |
0 |
try { |
| 2153 |
0 |
Version[] revisions = getVersioningStore(context).getXWikiDocVersions(this, context); |
| 2154 |
0 |
int length = nb; |
| 2155 |
|
|
| 2156 |
0 |
if (nb == 0) { |
| 2157 |
0 |
length = revisions.length; |
| 2158 |
|
} |
| 2159 |
|
|
| 2160 |
0 |
if (revisions.length < length) { |
| 2161 |
0 |
length = revisions.length; |
| 2162 |
|
} |
| 2163 |
|
|
| 2164 |
0 |
String[] recentrevs = new String[length]; |
| 2165 |
0 |
for (int i = 1; i <= length; i++) { |
| 2166 |
0 |
recentrevs[i - 1] = revisions[revisions.length - i].toString(); |
| 2167 |
|
} |
| 2168 |
0 |
return recentrevs; |
| 2169 |
|
} catch (Exception e) { |
| 2170 |
0 |
return new String[0]; |
| 2171 |
|
} |
| 2172 |
|
} |
| 2173 |
|
|
| 2174 |
|
|
| 2175 |
|
|
| 2176 |
|
|
| 2177 |
|
@param |
| 2178 |
|
@return |
| 2179 |
|
|
| |
|
| 82.9% |
Uncovered Elements: 6 (35) |
Complexity: 13 |
Complexity Density: 0.62 |
|
| 2180 |
14 |
public List<String> getRevisions(RevisionCriteria criteria, XWikiContext context) throws XWikiException... |
| 2181 |
|
{ |
| 2182 |
14 |
List<String> results = new ArrayList<String>(); |
| 2183 |
|
|
| 2184 |
14 |
Version[] revisions = getRevisions(context); |
| 2185 |
|
|
| 2186 |
14 |
XWikiRCSNodeInfo nextNodeinfo = null; |
| 2187 |
14 |
XWikiRCSNodeInfo nodeinfo; |
| 2188 |
14 |
for (Version revision : revisions) { |
| 2189 |
22 |
nodeinfo = nextNodeinfo; |
| 2190 |
22 |
nextNodeinfo = getRevisionInfo(revision.toString(), context); |
| 2191 |
|
|
| 2192 |
22 |
if (nodeinfo == null) { |
| 2193 |
14 |
continue; |
| 2194 |
|
} |
| 2195 |
|
|
| 2196 |
|
|
| 2197 |
8 |
if (criteria.getIncludeMinorVersions() || !nextNodeinfo.isMinorEdit()) { |
| 2198 |
|
|
| 2199 |
8 |
if (criteria.getAuthor().equals("") || criteria.getAuthor().equals(nodeinfo.getAuthor())) { |
| 2200 |
|
|
| 2201 |
8 |
Date versionDate = nodeinfo.getDate(); |
| 2202 |
8 |
if (versionDate.after(criteria.getMinDate()) && versionDate.before(criteria.getMaxDate())) { |
| 2203 |
8 |
results.add(nodeinfo.getVersion().toString()); |
| 2204 |
|
} |
| 2205 |
|
} |
| 2206 |
|
} |
| 2207 |
|
} |
| 2208 |
|
|
| 2209 |
14 |
nodeinfo = nextNodeinfo; |
| 2210 |
14 |
if (nodeinfo != null) { |
| 2211 |
14 |
if (criteria.getAuthor().equals("") || criteria.getAuthor().equals(nodeinfo.getAuthor())) { |
| 2212 |
|
|
| 2213 |
14 |
Date versionDate = nodeinfo.getDate(); |
| 2214 |
14 |
if (versionDate.after(criteria.getMinDate()) && versionDate.before(criteria.getMaxDate())) { |
| 2215 |
14 |
results.add(nodeinfo.getVersion().toString()); |
| 2216 |
|
} |
| 2217 |
|
} |
| 2218 |
|
} |
| 2219 |
|
|
| 2220 |
14 |
return criteria.getRange().subList(results); |
| 2221 |
|
} |
| 2222 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2223 |
33 |
public XWikiRCSNodeInfo getRevisionInfo(String version, XWikiContext context) throws XWikiException... |
| 2224 |
|
{ |
| 2225 |
33 |
return getDocumentArchive(context).getNode(new Version(version)); |
| 2226 |
|
} |
| 2227 |
|
|
| 2228 |
|
|
| 2229 |
|
@return |
| 2230 |
|
|
| 2231 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2232 |
31329 |
public boolean isMostRecent()... |
| 2233 |
|
{ |
| 2234 |
31331 |
return this.mostRecent; |
| 2235 |
|
} |
| 2236 |
|
|
| 2237 |
|
|
| 2238 |
|
|
| 2239 |
|
|
| 2240 |
|
@param |
| 2241 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2242 |
34969 |
public void setMostRecent(boolean mostRecent)... |
| 2243 |
|
{ |
| 2244 |
34976 |
this.mostRecent = mostRecent; |
| 2245 |
|
} |
| 2246 |
|
|
| 2247 |
|
|
| 2248 |
|
@since |
| 2249 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 2250 |
73220 |
public BaseClass getXClass()... |
| 2251 |
|
{ |
| 2252 |
73220 |
if (this.xClass == null) { |
| 2253 |
15094 |
BaseClass emptyClass = new BaseClass(); |
| 2254 |
|
|
| 2255 |
15094 |
emptyClass.setDirty(false); |
| 2256 |
|
|
| 2257 |
15094 |
this.setXClass(emptyClass); |
| 2258 |
|
} |
| 2259 |
73220 |
return this.xClass; |
| 2260 |
|
} |
| 2261 |
|
|
| 2262 |
|
|
| 2263 |
|
@since |
| 2264 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 2265 |
39434 |
public void setXClass(BaseClass xwikiClass)... |
| 2266 |
|
{ |
| 2267 |
39435 |
xwikiClass.setOwnerDocument(this); |
| 2268 |
|
|
| 2269 |
39432 |
this.xClass = xwikiClass; |
| 2270 |
|
} |
| 2271 |
|
|
| 2272 |
|
|
| 2273 |
|
@since |
| 2274 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2275 |
285444 |
public Map<DocumentReference, List<BaseObject>> getXObjects()... |
| 2276 |
|
{ |
| 2277 |
285437 |
return this.xObjects; |
| 2278 |
|
} |
| 2279 |
|
|
| 2280 |
|
|
| 2281 |
|
@since |
| 2282 |
|
|
| |
|
| 50% |
Uncovered Elements: 7 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 2283 |
34 |
public void setXObjects(Map<DocumentReference, List<BaseObject>> objects)... |
| 2284 |
|
{ |
| 2285 |
34 |
if (objects == null) { |
| 2286 |
|
|
| 2287 |
0 |
objects = new HashMap<>(); |
| 2288 |
|
} |
| 2289 |
|
|
| 2290 |
34 |
boolean isDirty = false; |
| 2291 |
|
|
| 2292 |
34 |
for (List<BaseObject> objList : objects.values()) { |
| 2293 |
0 |
for (BaseObject obj : objList) { |
| 2294 |
0 |
obj.setOwnerDocument(this); |
| 2295 |
0 |
isDirty = true; |
| 2296 |
|
} |
| 2297 |
|
} |
| 2298 |
|
|
| 2299 |
|
|
| 2300 |
34 |
if (isDirty) { |
| 2301 |
0 |
setMetaDataDirty(true); |
| 2302 |
|
} |
| 2303 |
|
|
| 2304 |
|
|
| 2305 |
34 |
this.xObjects = objects; |
| 2306 |
|
} |
| 2307 |
|
|
| 2308 |
|
|
| 2309 |
|
@since |
| 2310 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2311 |
65 |
public BaseObject getXObject()... |
| 2312 |
|
{ |
| 2313 |
65 |
return getXObject(getDocumentReference()); |
| 2314 |
|
} |
| 2315 |
|
|
| 2316 |
|
|
| 2317 |
|
@deprecated@link |
| 2318 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2319 |
0 |
@Deprecated... |
| 2320 |
|
public BaseObject getxWikiObject() |
| 2321 |
|
{ |
| 2322 |
0 |
return getXObject(getDocumentReference()); |
| 2323 |
|
} |
| 2324 |
|
|
| 2325 |
|
|
| 2326 |
|
@since |
| 2327 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 3 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 2328 |
44 |
public List<BaseClass> getXClasses(XWikiContext context)... |
| 2329 |
|
{ |
| 2330 |
44 |
List<BaseClass> list = new ArrayList<BaseClass>(); |
| 2331 |
|
|
| 2332 |
|
|
| 2333 |
44 |
for (DocumentReference classReference : getXObjects().keySet()) { |
| 2334 |
68 |
BaseClass bclass = null; |
| 2335 |
68 |
List<BaseObject> objects = getXObjects(classReference); |
| 2336 |
68 |
for (BaseObject obj : objects) { |
| 2337 |
68 |
if (obj != null) { |
| 2338 |
68 |
bclass = obj.getXClass(context); |
| 2339 |
68 |
if (bclass != null) { |
| 2340 |
68 |
break; |
| 2341 |
|
} |
| 2342 |
|
} |
| 2343 |
|
} |
| 2344 |
68 |
if (bclass != null) { |
| 2345 |
68 |
list.add(bclass); |
| 2346 |
|
} |
| 2347 |
|
} |
| 2348 |
44 |
return list; |
| 2349 |
|
} |
| 2350 |
|
|
| 2351 |
|
|
| 2352 |
|
|
| 2353 |
|
|
| 2354 |
|
|
| 2355 |
|
|
| 2356 |
|
|
| 2357 |
|
@param |
| 2358 |
|
@param |
| 2359 |
|
@return |
| 2360 |
|
@throws |
| 2361 |
|
@since |
| 2362 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
| 2363 |
1546 |
public int createXObject(EntityReference classReference, XWikiContext context) throws XWikiException... |
| 2364 |
|
{ |
| 2365 |
1546 |
DocumentReference absoluteClassReference = resolveClassReference(classReference); |
| 2366 |
1546 |
BaseObject object = BaseClass.newCustomClassInstance(absoluteClassReference, context); |
| 2367 |
1546 |
object.setOwnerDocument(this); |
| 2368 |
1546 |
object.setXClassReference(classReference); |
| 2369 |
1546 |
List<BaseObject> objects = this.xObjects.get(absoluteClassReference); |
| 2370 |
1546 |
if (objects == null) { |
| 2371 |
1470 |
objects = new ArrayList<BaseObject>(); |
| 2372 |
1470 |
this.xObjects.put(absoluteClassReference, objects); |
| 2373 |
|
} |
| 2374 |
1546 |
objects.add(object); |
| 2375 |
1546 |
int nb = objects.size() - 1; |
| 2376 |
1546 |
object.setNumber(nb); |
| 2377 |
1546 |
setMetaDataDirty(true); |
| 2378 |
1546 |
return nb; |
| 2379 |
|
} |
| 2380 |
|
|
| 2381 |
|
|
| 2382 |
|
@deprecated@link |
| 2383 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2384 |
89 |
@Deprecated... |
| 2385 |
|
public int createNewObject(String className, XWikiContext context) throws XWikiException |
| 2386 |
|
{ |
| 2387 |
89 |
return createXObject( |
| 2388 |
|
getXClassEntityReferenceResolver().resolve(className, EntityType.DOCUMENT, getDocumentReference()), |
| 2389 |
|
context); |
| 2390 |
|
} |
| 2391 |
|
|
| 2392 |
|
|
| 2393 |
|
@since |
| 2394 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 2395 |
508 |
public int getXObjectSize(DocumentReference classReference)... |
| 2396 |
|
{ |
| 2397 |
508 |
try { |
| 2398 |
508 |
return getXObjects().get(classReference).size(); |
| 2399 |
|
} catch (Exception e) { |
| 2400 |
479 |
return 0; |
| 2401 |
|
} |
| 2402 |
|
} |
| 2403 |
|
|
| 2404 |
|
|
| 2405 |
|
@since |
| 2406 |
|
@since |
| 2407 |
|
@since |
| 2408 |
|
@since |
| 2409 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2410 |
0 |
public int getXObjectSize(EntityReference classReference)... |
| 2411 |
|
{ |
| 2412 |
0 |
return getXObjectSize(resolveClassReference(classReference)); |
| 2413 |
|
} |
| 2414 |
|
|
| 2415 |
|
|
| 2416 |
|
@deprecated@link |
| 2417 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2418 |
0 |
@Deprecated... |
| 2419 |
|
public int getObjectNumbers(String className) |
| 2420 |
|
{ |
| 2421 |
0 |
return getXObjectSize(resolveClassReference(className)); |
| 2422 |
|
} |
| 2423 |
|
|
| 2424 |
|
|
| 2425 |
|
@since |
| 2426 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 2427 |
64744 |
public List<BaseObject> getXObjects(DocumentReference classReference)... |
| 2428 |
|
{ |
| 2429 |
64743 |
if (classReference == null) { |
| 2430 |
0 |
return new ArrayList<BaseObject>(); |
| 2431 |
|
} |
| 2432 |
|
|
| 2433 |
64741 |
return getXObjects().get(classReference); |
| 2434 |
|
} |
| 2435 |
|
|
| 2436 |
|
|
| 2437 |
|
@since |
| 2438 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 2439 |
19766 |
public List<BaseObject> getXObjects(EntityReference reference)... |
| 2440 |
|
{ |
| 2441 |
19766 |
if (reference.getType() == EntityType.DOCUMENT) { |
| 2442 |
|
|
| 2443 |
19765 |
return getXObjects( |
| 2444 |
|
getCurrentReferenceDocumentReferenceResolver().resolve(reference, getDocumentReference())); |
| 2445 |
|
} |
| 2446 |
|
|
| 2447 |
0 |
return Collections.emptyList(); |
| 2448 |
|
} |
| 2449 |
|
|
| 2450 |
|
|
| 2451 |
|
@deprecated@link |
| 2452 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 2453 |
15497 |
@Deprecated... |
| 2454 |
|
public Vector<BaseObject> getObjects(String className) |
| 2455 |
|
{ |
| 2456 |
15495 |
List<BaseObject> result = this.xObjects.get(resolveClassReference(className)); |
| 2457 |
15496 |
return result == null ? null : new Vector<BaseObject>(result); |
| 2458 |
|
} |
| 2459 |
|
|
| 2460 |
|
|
| 2461 |
|
@since |
| 2462 |
|
|
| |
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 2463 |
1 |
public void setXObjects(DocumentReference classReference, List<BaseObject> objects)... |
| 2464 |
|
{ |
| 2465 |
|
|
| 2466 |
1 |
List<BaseObject> existingbjects = this.xObjects.get(classReference); |
| 2467 |
1 |
if (existingbjects != null) { |
| 2468 |
1 |
existingbjects.clear(); |
| 2469 |
|
} |
| 2470 |
|
|
| 2471 |
1 |
for (BaseObject obj : objects) { |
| 2472 |
1 |
obj.setOwnerDocument(this); |
| 2473 |
|
} |
| 2474 |
|
|
| 2475 |
|
|
| 2476 |
1 |
if (objects.isEmpty()) { |
| 2477 |
|
|
| 2478 |
|
|
| 2479 |
|
|
| 2480 |
0 |
this.xObjects.put(classReference, objects); |
| 2481 |
|
} else { |
| 2482 |
1 |
for (BaseObject baseObject : objects) { |
| 2483 |
1 |
addXObject(classReference, baseObject); |
| 2484 |
|
} |
| 2485 |
|
} |
| 2486 |
|
|
| 2487 |
1 |
setMetaDataDirty(true); |
| 2488 |
|
} |
| 2489 |
|
|
| 2490 |
|
|
| 2491 |
|
@since |
| 2492 |
|
|
| |
|
| 69.2% |
Uncovered Elements: 4 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 2493 |
50992 |
public BaseObject getXObject(EntityReference reference)... |
| 2494 |
|
{ |
| 2495 |
50995 |
if (reference instanceof DocumentReference) { |
| 2496 |
0 |
return getXObject((DocumentReference) reference); |
| 2497 |
50993 |
} else if (reference.getType() == EntityType.DOCUMENT) { |
| 2498 |
|
|
| 2499 |
44267 |
return getXObject( |
| 2500 |
|
getCurrentReferenceDocumentReferenceResolver().resolve(reference, getDocumentReference())); |
| 2501 |
6715 |
} else if (reference.getType() == EntityType.OBJECT) { |
| 2502 |
|
|
| 2503 |
6717 |
return getXObject(getCurrentReferenceObjectReferenceResolver().resolve(reference, getDocumentReference())); |
| 2504 |
|
} |
| 2505 |
|
|
| 2506 |
0 |
return null; |
| 2507 |
|
} |
| 2508 |
|
|
| 2509 |
|
|
| 2510 |
|
@since |
| 2511 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 2512 |
107022 |
public BaseObject getXObject(DocumentReference classReference)... |
| 2513 |
|
{ |
| 2514 |
107021 |
BaseObject result = null; |
| 2515 |
107009 |
List<BaseObject> objects = getXObjects().get(classReference); |
| 2516 |
107017 |
if (objects != null) { |
| 2517 |
22176 |
for (BaseObject object : objects) { |
| 2518 |
22178 |
if (object != null) { |
| 2519 |
22172 |
result = object; |
| 2520 |
22172 |
break; |
| 2521 |
|
} |
| 2522 |
|
} |
| 2523 |
|
} |
| 2524 |
107016 |
return result; |
| 2525 |
|
} |
| 2526 |
|
|
| 2527 |
|
|
| 2528 |
|
|
| 2529 |
|
|
| 2530 |
|
@param |
| 2531 |
|
@return |
| 2532 |
|
@since |
| 2533 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 2534 |
9845 |
public BaseObject getXObject(ObjectReference objectReference)... |
| 2535 |
|
{ |
| 2536 |
9844 |
BaseObjectReference baseObjectReference; |
| 2537 |
9847 |
if (objectReference instanceof BaseObjectReference) { |
| 2538 |
3130 |
baseObjectReference = (BaseObjectReference) objectReference; |
| 2539 |
|
} else { |
| 2540 |
6717 |
baseObjectReference = new BaseObjectReference(objectReference); |
| 2541 |
|
} |
| 2542 |
|
|
| 2543 |
|
|
| 2544 |
|
|
| 2545 |
9849 |
return baseObjectReference.getObjectNumber() == null ? this.getXObject(baseObjectReference.getXClassReference()) |
| 2546 |
|
: getXObject(baseObjectReference.getXClassReference(), baseObjectReference.getObjectNumber()); |
| 2547 |
|
} |
| 2548 |
|
|
| 2549 |
|
|
| 2550 |
|
|
| 2551 |
|
|
| 2552 |
|
@param |
| 2553 |
|
@return |
| 2554 |
|
@since |
| 2555 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 2556 |
2401 |
public BaseProperty<ObjectPropertyReference> getXObjectProperty(ObjectPropertyReference objectPropertyReference)... |
| 2557 |
|
{ |
| 2558 |
2401 |
BaseObject object = getXObject((ObjectReference) objectPropertyReference.getParent()); |
| 2559 |
|
|
| 2560 |
2401 |
if (object != null) { |
| 2561 |
2400 |
return (BaseProperty<ObjectPropertyReference>) object.getField(objectPropertyReference.getName()); |
| 2562 |
|
} |
| 2563 |
|
|
| 2564 |
1 |
return null; |
| 2565 |
|
} |
| 2566 |
|
|
| 2567 |
|
|
| 2568 |
|
@deprecated@link |
| 2569 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2570 |
13853 |
@Deprecated... |
| 2571 |
|
public BaseObject getObject(String className) |
| 2572 |
|
{ |
| 2573 |
13854 |
return getXObject(resolveClassReference(className)); |
| 2574 |
|
} |
| 2575 |
|
|
| 2576 |
|
|
| 2577 |
|
@since |
| 2578 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 2579 |
22352 |
public BaseObject getXObject(DocumentReference classReference, int nb)... |
| 2580 |
|
{ |
| 2581 |
22353 |
List<BaseObject> objects = getXObjects().get(classReference); |
| 2582 |
|
|
| 2583 |
22353 |
if (objects != null && objects.size() > nb) { |
| 2584 |
17487 |
return objects.get(nb); |
| 2585 |
|
} |
| 2586 |
|
|
| 2587 |
4867 |
return null; |
| 2588 |
|
} |
| 2589 |
|
|
| 2590 |
|
|
| 2591 |
|
|
| 2592 |
|
|
| 2593 |
|
|
| 2594 |
|
|
| 2595 |
|
@param |
| 2596 |
|
@param |
| 2597 |
|
@param |
| 2598 |
|
@param |
| 2599 |
|
@return@link |
| 2600 |
|
@throws |
| 2601 |
|
@since |
| 2602 |
|
@since |
| 2603 |
|
@since |
| 2604 |
|
@since |
| 2605 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 2606 |
0 |
public BaseObject getXObject(EntityReference classReference, int number, boolean create, XWikiContext xcontext)... |
| 2607 |
|
throws XWikiException |
| 2608 |
|
{ |
| 2609 |
0 |
DocumentReference absoluteClassReference = resolveClassReference(classReference); |
| 2610 |
|
|
| 2611 |
0 |
BaseObject xobject = getXObject(absoluteClassReference); |
| 2612 |
|
|
| 2613 |
0 |
if (xobject == null && create) { |
| 2614 |
0 |
xobject = BaseClass.newCustomClassInstance(absoluteClassReference, xcontext); |
| 2615 |
|
|
| 2616 |
0 |
setXObject(number, xobject); |
| 2617 |
|
} |
| 2618 |
|
|
| 2619 |
0 |
return xobject; |
| 2620 |
|
} |
| 2621 |
|
|
| 2622 |
|
|
| 2623 |
|
@since |
| 2624 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2625 |
54 |
public BaseObject getXObject(EntityReference classReference, int nb)... |
| 2626 |
|
{ |
| 2627 |
54 |
return getXObject( |
| 2628 |
|
getCurrentReferenceDocumentReferenceResolver().resolve(classReference, getDocumentReference()), nb); |
| 2629 |
|
} |
| 2630 |
|
|
| 2631 |
|
|
| 2632 |
|
@deprecated@link |
| 2633 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2634 |
8047 |
@Deprecated... |
| 2635 |
|
public BaseObject getObject(String className, int nb) |
| 2636 |
|
{ |
| 2637 |
8048 |
return getXObject(resolveClassReference(className), nb); |
| 2638 |
|
} |
| 2639 |
|
|
| 2640 |
|
|
| 2641 |
|
@since |
| 2642 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2643 |
0 |
public BaseObject getXObject(DocumentReference classReference, String key, String value)... |
| 2644 |
|
{ |
| 2645 |
0 |
return getXObject(classReference, key, value, false); |
| 2646 |
|
} |
| 2647 |
|
|
| 2648 |
|
|
| 2649 |
|
@deprecated@link |
| 2650 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2651 |
241 |
@Deprecated... |
| 2652 |
|
public BaseObject getObject(String className, String key, String value) |
| 2653 |
|
{ |
| 2654 |
241 |
return getObject(className, key, value, false); |
| 2655 |
|
} |
| 2656 |
|
|
| 2657 |
|
|
| 2658 |
|
@return |
| 2659 |
|
|
| |
|
| 55.6% |
Uncovered Elements: 4 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 2660 |
12747 |
public BaseObject getXObject(EntityReference reference, String key, String value, boolean failover)... |
| 2661 |
|
{ |
| 2662 |
12745 |
if (reference instanceof DocumentReference) { |
| 2663 |
0 |
return getXObject((DocumentReference) reference, key, value, failover); |
| 2664 |
12744 |
} else if (reference.getType() == EntityType.DOCUMENT) { |
| 2665 |
|
|
| 2666 |
12744 |
return getXObject(getCurrentReferenceDocumentReferenceResolver().resolve(reference, getDocumentReference()), |
| 2667 |
|
key, value, failover); |
| 2668 |
|
} |
| 2669 |
|
|
| 2670 |
0 |
return null; |
| 2671 |
|
} |
| 2672 |
|
|
| 2673 |
|
|
| 2674 |
|
@since |
| 2675 |
|
|
| |
|
| 60.6% |
Uncovered Elements: 13 (33) |
Complexity: 10 |
Complexity Density: 0.53 |
|
| 2676 |
13164 |
public BaseObject getXObject(DocumentReference classReference, String key, String value, boolean failover)... |
| 2677 |
|
{ |
| 2678 |
13165 |
try { |
| 2679 |
13167 |
if (value == null) { |
| 2680 |
0 |
if (failover) { |
| 2681 |
0 |
return getXObject(classReference); |
| 2682 |
|
} else { |
| 2683 |
0 |
return null; |
| 2684 |
|
} |
| 2685 |
|
} |
| 2686 |
|
|
| 2687 |
13165 |
List<BaseObject> objects = getXObjects().get(classReference); |
| 2688 |
13161 |
if ((objects == null) || (objects.size() == 0)) { |
| 2689 |
11690 |
return null; |
| 2690 |
|
} |
| 2691 |
1476 |
for (BaseObject obj : objects) { |
| 2692 |
1687 |
if (obj != null) { |
| 2693 |
1687 |
if (value.equals(obj.getStringValue(key))) { |
| 2694 |
277 |
return obj; |
| 2695 |
|
} |
| 2696 |
|
} |
| 2697 |
|
} |
| 2698 |
|
|
| 2699 |
1199 |
if (failover) { |
| 2700 |
1174 |
return getXObject(classReference); |
| 2701 |
|
} else { |
| 2702 |
25 |
return null; |
| 2703 |
|
} |
| 2704 |
|
} catch (Exception e) { |
| 2705 |
0 |
if (failover) { |
| 2706 |
0 |
return getXObject(classReference); |
| 2707 |
|
} |
| 2708 |
|
|
| 2709 |
0 |
LOGGER.warn("Exception while accessing objects for document [{}]: {}", getDocumentReference(), |
| 2710 |
|
e.getMessage(), e); |
| 2711 |
0 |
return null; |
| 2712 |
|
} |
| 2713 |
|
} |
| 2714 |
|
|
| 2715 |
|
|
| 2716 |
|
@deprecated@link |
| 2717 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2718 |
404 |
@Deprecated... |
| 2719 |
|
public BaseObject getObject(String className, String key, String value, boolean failover) |
| 2720 |
|
{ |
| 2721 |
404 |
return getXObject(resolveClassReference(className), key, value, failover); |
| 2722 |
|
} |
| 2723 |
|
|
| 2724 |
|
|
| 2725 |
|
@since |
| 2726 |
|
@deprecated@link |
| 2727 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 2728 |
615 |
@Deprecated... |
| 2729 |
|
public void addXObject(DocumentReference classReference, BaseObject object) |
| 2730 |
|
{ |
| 2731 |
615 |
List<BaseObject> vobj = this.xObjects.get(classReference); |
| 2732 |
615 |
if (vobj == null) { |
| 2733 |
231 |
setXObject(classReference, 0, object); |
| 2734 |
|
} else { |
| 2735 |
384 |
setXObject(classReference, vobj.size(), object); |
| 2736 |
|
} |
| 2737 |
|
} |
| 2738 |
|
|
| 2739 |
|
|
| 2740 |
|
|
| 2741 |
|
|
| 2742 |
|
@param |
| 2743 |
|
@throws |
| 2744 |
|
|
| 2745 |
|
@since |
| 2746 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 2747 |
31339 |
public void addXObject(BaseObject object)... |
| 2748 |
|
{ |
| 2749 |
31338 |
object.setOwnerDocument(this); |
| 2750 |
|
|
| 2751 |
31340 |
List<BaseObject> vobj = this.xObjects.get(object.getXClassReference()); |
| 2752 |
31339 |
if (vobj == null) { |
| 2753 |
26829 |
setXObject(0, object); |
| 2754 |
|
} else { |
| 2755 |
4510 |
setXObject(vobj.size(), object); |
| 2756 |
|
} |
| 2757 |
|
} |
| 2758 |
|
|
| 2759 |
|
|
| 2760 |
|
@deprecated@link |
| 2761 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2762 |
9 |
@Deprecated... |
| 2763 |
|
public void addObject(String className, BaseObject object) |
| 2764 |
|
{ |
| 2765 |
9 |
addXObject(resolveClassReference(className), object); |
| 2766 |
|
} |
| 2767 |
|
|
| 2768 |
|
|
| 2769 |
|
@since |
| 2770 |
|
@deprecated@link |
| 2771 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
| 2772 |
616 |
@Deprecated... |
| 2773 |
|
public void setXObject(DocumentReference classReference, int nb, BaseObject object) |
| 2774 |
|
{ |
| 2775 |
616 |
if (object != null) { |
| 2776 |
15 |
object.setOwnerDocument(this); |
| 2777 |
15 |
object.setNumber(nb); |
| 2778 |
|
} |
| 2779 |
|
|
| 2780 |
616 |
List<BaseObject> objects = this.xObjects.get(classReference); |
| 2781 |
616 |
if (objects == null) { |
| 2782 |
232 |
objects = new ArrayList<BaseObject>(); |
| 2783 |
232 |
this.xObjects.put(classReference, objects); |
| 2784 |
|
} |
| 2785 |
1232 |
while (nb >= objects.size()) { |
| 2786 |
616 |
objects.add(null); |
| 2787 |
|
} |
| 2788 |
616 |
objects.set(nb, object); |
| 2789 |
616 |
setMetaDataDirty(true); |
| 2790 |
|
} |
| 2791 |
|
|
| 2792 |
|
|
| 2793 |
|
|
| 2794 |
|
|
| 2795 |
|
@param |
| 2796 |
|
@param |
| 2797 |
|
@throws |
| 2798 |
|
|
| 2799 |
|
@since |
| 2800 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 2801 |
39462 |
public void setXObject(int nb, BaseObject object)... |
| 2802 |
|
{ |
| 2803 |
39462 |
object.setOwnerDocument(this); |
| 2804 |
39463 |
object.setNumber(nb); |
| 2805 |
|
|
| 2806 |
39462 |
List<BaseObject> objects = this.xObjects.get(object.getXClassReference()); |
| 2807 |
39462 |
if (objects == null) { |
| 2808 |
32565 |
objects = new ArrayList<BaseObject>(); |
| 2809 |
32564 |
this.xObjects.put(object.getXClassReference(), objects); |
| 2810 |
|
} |
| 2811 |
79060 |
while (nb >= objects.size()) { |
| 2812 |
39595 |
objects.add(null); |
| 2813 |
|
} |
| 2814 |
39462 |
objects.set(nb, object); |
| 2815 |
39458 |
setMetaDataDirty(true); |
| 2816 |
|
} |
| 2817 |
|
|
| 2818 |
|
|
| 2819 |
|
@deprecated@link |
| 2820 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2821 |
0 |
@Deprecated... |
| 2822 |
|
public void setObject(String className, int nb, BaseObject object) |
| 2823 |
|
{ |
| 2824 |
0 |
setXObject(resolveClassReference(className), nb, object); |
| 2825 |
|
} |
| 2826 |
|
|
| 2827 |
|
|
| 2828 |
|
@return |
| 2829 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2830 |
595287 |
public boolean isNew()... |
| 2831 |
|
{ |
| 2832 |
595288 |
return this.isNew; |
| 2833 |
|
} |
| 2834 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2835 |
473712 |
public void setNew(boolean aNew)... |
| 2836 |
|
{ |
| 2837 |
473704 |
this.isNew = aNew; |
| 2838 |
|
} |
| 2839 |
|
|
| 2840 |
|
|
| 2841 |
|
@since |
| 2842 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 2843 |
0 |
public void mergeXClass(XWikiDocument templatedoc)... |
| 2844 |
|
{ |
| 2845 |
0 |
BaseClass bclass = getXClass(); |
| 2846 |
0 |
BaseClass tbclass = templatedoc.getXClass(); |
| 2847 |
0 |
if (tbclass != null) { |
| 2848 |
0 |
if (bclass == null) { |
| 2849 |
0 |
setXClass(tbclass.clone()); |
| 2850 |
|
} else { |
| 2851 |
0 |
getXClass().merge(tbclass.clone()); |
| 2852 |
|
} |
| 2853 |
|
} |
| 2854 |
0 |
setMetaDataDirty(true); |
| 2855 |
|
} |
| 2856 |
|
|
| 2857 |
|
|
| 2858 |
|
@deprecated@link |
| 2859 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2860 |
0 |
@Deprecated... |
| 2861 |
|
public void mergexWikiClass(XWikiDocument templatedoc) |
| 2862 |
|
{ |
| 2863 |
0 |
mergeXClass(templatedoc); |
| 2864 |
|
} |
| 2865 |
|
|
| 2866 |
|
|
| 2867 |
|
@since |
| 2868 |
|
|
| |
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 2869 |
37 |
public void mergeXObjects(XWikiDocument templateDoc)... |
| 2870 |
|
{ |
| 2871 |
37 |
for (Map.Entry<DocumentReference, List<BaseObject>> entry : templateDoc.getXObjects().entrySet()) { |
| 2872 |
|
|
| 2873 |
|
|
| 2874 |
31 |
DocumentReference classReference = entry.getKey().replaceParent(entry.getKey().getWikiReference(), |
| 2875 |
|
getDocumentReference().getWikiReference()); |
| 2876 |
|
|
| 2877 |
|
|
| 2878 |
|
|
| 2879 |
|
|
| 2880 |
31 |
if (getXObjectSize(classReference) == 0) { |
| 2881 |
30 |
for (BaseObject object : entry.getValue()) { |
| 2882 |
32 |
if (object != null) { |
| 2883 |
32 |
addXObject(object.duplicate()); |
| 2884 |
|
} |
| 2885 |
|
} |
| 2886 |
|
} |
| 2887 |
|
} |
| 2888 |
|
} |
| 2889 |
|
|
| 2890 |
|
|
| 2891 |
|
@deprecated@link |
| 2892 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2893 |
0 |
@Deprecated... |
| 2894 |
|
public void mergexWikiObjects(XWikiDocument templatedoc) |
| 2895 |
|
{ |
| 2896 |
0 |
mergeXObjects(templatedoc); |
| 2897 |
|
} |
| 2898 |
|
|
| 2899 |
|
|
| 2900 |
|
@since |
| 2901 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2902 |
31201 |
public void cloneXObjects(XWikiDocument templatedoc)... |
| 2903 |
|
{ |
| 2904 |
31195 |
cloneXObjects(templatedoc, true); |
| 2905 |
|
} |
| 2906 |
|
|
| 2907 |
|
|
| 2908 |
|
@since |
| 2909 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2910 |
131 |
public void duplicateXObjects(XWikiDocument templatedoc)... |
| 2911 |
|
{ |
| 2912 |
131 |
cloneXObjects(templatedoc, false); |
| 2913 |
|
} |
| 2914 |
|
|
| 2915 |
|
|
| 2916 |
|
|
| 2917 |
|
|
| 2918 |
|
@param |
| 2919 |
|
@param |
| 2920 |
|
|
| 2921 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
| 2922 |
31324 |
private void cloneXObjects(XWikiDocument templatedoc, boolean keepsIdentity)... |
| 2923 |
|
{ |
| 2924 |
|
|
| 2925 |
31321 |
this.xObjects.clear(); |
| 2926 |
|
|
| 2927 |
|
|
| 2928 |
31326 |
for (Map.Entry<DocumentReference, List<BaseObject>> entry : templatedoc.getXObjects().entrySet()) { |
| 2929 |
26991 |
List<BaseObject> tobjects = entry.getValue(); |
| 2930 |
|
|
| 2931 |
|
|
| 2932 |
26990 |
for (BaseObject otherObject : tobjects) { |
| 2933 |
31825 |
if (otherObject != null) { |
| 2934 |
31220 |
if (keepsIdentity) { |
| 2935 |
31118 |
addXObject(otherObject.clone()); |
| 2936 |
|
} else { |
| 2937 |
102 |
BaseObject newObject = otherObject.duplicate(getDocumentReference()); |
| 2938 |
102 |
setXObject(newObject.getNumber(), newObject); |
| 2939 |
|
} |
| 2940 |
602 |
} else if (keepsIdentity) { |
| 2941 |
|
|
| 2942 |
600 |
addXObject(entry.getKey(), null); |
| 2943 |
|
} |
| 2944 |
|
} |
| 2945 |
|
} |
| 2946 |
|
} |
| 2947 |
|
|
| 2948 |
|
|
| 2949 |
|
@since |
| 2950 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2951 |
62685 |
public DocumentReference getTemplateDocumentReference()... |
| 2952 |
|
{ |
| 2953 |
62687 |
return this.templateDocumentReference; |
| 2954 |
|
} |
| 2955 |
|
|
| 2956 |
|
|
| 2957 |
|
@deprecated@link |
| 2958 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 2959 |
0 |
@Deprecated... |
| 2960 |
|
public String getTemplate() |
| 2961 |
|
{ |
| 2962 |
0 |
String templateReferenceAsString; |
| 2963 |
0 |
DocumentReference templateDocumentReference = getTemplateDocumentReference(); |
| 2964 |
0 |
if (templateDocumentReference != null) { |
| 2965 |
0 |
templateReferenceAsString = LOCAL_REFERENCE_SERIALIZER.serialize(templateDocumentReference); |
| 2966 |
|
} else { |
| 2967 |
0 |
templateReferenceAsString = ""; |
| 2968 |
|
} |
| 2969 |
0 |
return templateReferenceAsString; |
| 2970 |
|
} |
| 2971 |
|
|
| 2972 |
|
|
| 2973 |
|
@since |
| 2974 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 2975 |
31359 |
public void setTemplateDocumentReference(DocumentReference templateDocumentReference)... |
| 2976 |
|
{ |
| 2977 |
31361 |
if (!Objects.equals(getTemplateDocumentReference(), templateDocumentReference)) { |
| 2978 |
85 |
this.templateDocumentReference = templateDocumentReference; |
| 2979 |
85 |
setMetaDataDirty(true); |
| 2980 |
|
} |
| 2981 |
|
} |
| 2982 |
|
|
| 2983 |
|
|
| 2984 |
|
@deprecated@link |
| 2985 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 2986 |
0 |
@Deprecated... |
| 2987 |
|
public void setTemplate(String template) |
| 2988 |
|
{ |
| 2989 |
0 |
DocumentReference templateReference = null; |
| 2990 |
0 |
if (!StringUtils.isEmpty(template)) { |
| 2991 |
0 |
templateReference = getCurrentMixedDocumentReferenceResolver().resolve(template); |
| 2992 |
|
} |
| 2993 |
0 |
setTemplateDocumentReference(templateReference); |
| 2994 |
|
} |
| 2995 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2996 |
0 |
public String displayPrettyName(String fieldname, XWikiContext context)... |
| 2997 |
|
{ |
| 2998 |
0 |
return displayPrettyName(fieldname, false, true, context); |
| 2999 |
|
} |
| 3000 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3001 |
0 |
public String displayPrettyName(String fieldname, boolean showMandatory, XWikiContext context)... |
| 3002 |
|
{ |
| 3003 |
0 |
return displayPrettyName(fieldname, showMandatory, true, context); |
| 3004 |
|
} |
| 3005 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 3006 |
0 |
public String displayPrettyName(String fieldname, boolean showMandatory, boolean before, XWikiContext context)... |
| 3007 |
|
{ |
| 3008 |
0 |
try { |
| 3009 |
0 |
BaseObject object = getXObject(); |
| 3010 |
0 |
if (object == null) { |
| 3011 |
0 |
object = getFirstObject(fieldname, context); |
| 3012 |
|
} |
| 3013 |
0 |
return displayPrettyName(fieldname, showMandatory, before, object, context); |
| 3014 |
|
} catch (Exception e) { |
| 3015 |
0 |
return ""; |
| 3016 |
|
} |
| 3017 |
|
} |
| 3018 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3019 |
454 |
public String displayPrettyName(String fieldname, BaseObject obj, XWikiContext context)... |
| 3020 |
|
{ |
| 3021 |
454 |
return displayPrettyName(fieldname, false, true, obj, context); |
| 3022 |
|
} |
| 3023 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3024 |
0 |
public String displayPrettyName(String fieldname, boolean showMandatory, BaseObject obj, XWikiContext context)... |
| 3025 |
|
{ |
| 3026 |
0 |
return displayPrettyName(fieldname, showMandatory, true, obj, context); |
| 3027 |
|
} |
| 3028 |
|
|
| |
|
| 61.5% |
Uncovered Elements: 5 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 3029 |
454 |
public String displayPrettyName(String fieldname, boolean showMandatory, boolean before, BaseObject obj,... |
| 3030 |
|
XWikiContext context) |
| 3031 |
|
{ |
| 3032 |
454 |
try { |
| 3033 |
454 |
PropertyClass pclass = (PropertyClass) obj.getXClass(context).get(fieldname); |
| 3034 |
454 |
String dprettyName = ""; |
| 3035 |
454 |
if (showMandatory) { |
| 3036 |
0 |
dprettyName = context.getWiki().addMandatory(context); |
| 3037 |
|
} |
| 3038 |
454 |
if (before) { |
| 3039 |
454 |
return dprettyName + pclass.getPrettyName(context); |
| 3040 |
|
} else { |
| 3041 |
0 |
return pclass.getPrettyName(context) + dprettyName; |
| 3042 |
|
} |
| 3043 |
|
} catch (Exception e) { |
| 3044 |
0 |
return ""; |
| 3045 |
|
} |
| 3046 |
|
} |
| 3047 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 3048 |
0 |
public String displayTooltip(String fieldname, XWikiContext context)... |
| 3049 |
|
{ |
| 3050 |
0 |
try { |
| 3051 |
0 |
BaseObject object = getXObject(); |
| 3052 |
0 |
if (object == null) { |
| 3053 |
0 |
object = getFirstObject(fieldname, context); |
| 3054 |
|
} |
| 3055 |
0 |
return displayTooltip(fieldname, object, context); |
| 3056 |
|
} catch (Exception e) { |
| 3057 |
0 |
return ""; |
| 3058 |
|
} |
| 3059 |
|
} |
| 3060 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 3061 |
0 |
public String displayTooltip(String fieldname, BaseObject obj, XWikiContext context)... |
| 3062 |
|
{ |
| 3063 |
0 |
String result = ""; |
| 3064 |
|
|
| 3065 |
0 |
try { |
| 3066 |
0 |
PropertyClass pclass = (PropertyClass) obj.getXClass(context).get(fieldname); |
| 3067 |
0 |
String tooltip = pclass.getTooltip(context); |
| 3068 |
0 |
if ((tooltip != null) && (!tooltip.trim().equals(""))) { |
| 3069 |
0 |
String img = "<img src=\"" + context.getWiki().getSkinFile("info.gif", context) |
| 3070 |
|
+ "\" class=\"tooltip_image\" align=\"middle\" />"; |
| 3071 |
0 |
result = context.getWiki().addTooltip(img, tooltip, context); |
| 3072 |
|
} |
| 3073 |
|
} catch (Exception e) { |
| 3074 |
|
|
| 3075 |
|
} |
| 3076 |
|
|
| 3077 |
0 |
return result; |
| 3078 |
|
} |
| 3079 |
|
|
| 3080 |
|
|
| 3081 |
|
@param |
| 3082 |
|
@param |
| 3083 |
|
@return |
| 3084 |
|
|
| |
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 3085 |
43 |
public String display(String fieldname, XWikiContext context)... |
| 3086 |
|
{ |
| 3087 |
43 |
String result = ""; |
| 3088 |
|
|
| 3089 |
43 |
try { |
| 3090 |
43 |
BaseObject object = getXObject(); |
| 3091 |
43 |
if (object == null) { |
| 3092 |
41 |
object = getFirstObject(fieldname, context); |
| 3093 |
|
} |
| 3094 |
|
|
| 3095 |
43 |
result = display(fieldname, object, context); |
| 3096 |
|
} catch (Exception e) { |
| 3097 |
0 |
LOGGER.error("Failed to display field [" + fieldname + "] of document [" |
| 3098 |
|
+ getDefaultEntityReferenceSerializer().serialize(getDocumentReference()) + "]", e); |
| 3099 |
|
} |
| 3100 |
|
|
| 3101 |
43 |
return result; |
| 3102 |
|
} |
| 3103 |
|
|
| 3104 |
|
|
| 3105 |
|
@param |
| 3106 |
|
@param |
| 3107 |
|
@param |
| 3108 |
|
@return |
| 3109 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 3110 |
870 |
public String display(String fieldname, BaseObject obj, XWikiContext context)... |
| 3111 |
|
{ |
| 3112 |
870 |
String type = null; |
| 3113 |
870 |
try { |
| 3114 |
870 |
type = (String) context.get("display"); |
| 3115 |
|
} catch (Exception e) { |
| 3116 |
|
} |
| 3117 |
|
|
| 3118 |
870 |
if (type == null) { |
| 3119 |
700 |
type = "view"; |
| 3120 |
|
} |
| 3121 |
|
|
| 3122 |
870 |
return display(fieldname, type, obj, context); |
| 3123 |
|
} |
| 3124 |
|
|
| 3125 |
|
|
| 3126 |
|
@param |
| 3127 |
|
@param |
| 3128 |
|
@param |
| 3129 |
|
@return |
| 3130 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3131 |
9 |
public String display(String fieldname, String mode, XWikiContext context)... |
| 3132 |
|
{ |
| 3133 |
9 |
return display(fieldname, mode, "", context); |
| 3134 |
|
} |
| 3135 |
|
|
| 3136 |
|
|
| 3137 |
|
@param |
| 3138 |
|
@param |
| 3139 |
|
@param |
| 3140 |
|
@param |
| 3141 |
|
@return |
| 3142 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3143 |
1849 |
public String display(String fieldname, String type, BaseObject obj, XWikiContext context)... |
| 3144 |
|
{ |
| 3145 |
1849 |
return display(fieldname, type, "", obj, context); |
| 3146 |
|
} |
| 3147 |
|
|
| 3148 |
|
|
| 3149 |
|
@param |
| 3150 |
|
@param |
| 3151 |
|
@param |
| 3152 |
|
@param |
| 3153 |
|
@return |
| 3154 |
|
|
| |
|
| 58.3% |
Uncovered Elements: 5 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 3155 |
9 |
public String display(String fieldname, String mode, String prefix, XWikiContext context)... |
| 3156 |
|
{ |
| 3157 |
9 |
try { |
| 3158 |
9 |
BaseObject object = getXObject(); |
| 3159 |
9 |
if (object == null) { |
| 3160 |
0 |
object = getFirstObject(fieldname, context); |
| 3161 |
|
} |
| 3162 |
9 |
if (object == null) { |
| 3163 |
0 |
return ""; |
| 3164 |
|
} else { |
| 3165 |
9 |
return display(fieldname, mode, prefix, object, context); |
| 3166 |
|
} |
| 3167 |
|
} catch (Exception e) { |
| 3168 |
0 |
return ""; |
| 3169 |
|
} |
| 3170 |
|
} |
| 3171 |
|
|
| 3172 |
|
|
| 3173 |
|
@param |
| 3174 |
|
@param |
| 3175 |
|
@param |
| 3176 |
|
@param |
| 3177 |
|
|
| 3178 |
|
@param |
| 3179 |
|
@return |
| 3180 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3181 |
0 |
public String display(String fieldname, String type, BaseObject obj, String wrappingSyntaxId, XWikiContext context)... |
| 3182 |
|
{ |
| 3183 |
0 |
return display(fieldname, type, "", obj, wrappingSyntaxId, context); |
| 3184 |
|
} |
| 3185 |
|
|
| 3186 |
|
|
| 3187 |
|
@param |
| 3188 |
|
@param |
| 3189 |
|
@param |
| 3190 |
|
@param |
| 3191 |
|
@param |
| 3192 |
|
@return |
| 3193 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3194 |
1858 |
public String display(String fieldname, String type, String pref, BaseObject obj, XWikiContext context)... |
| 3195 |
|
{ |
| 3196 |
1858 |
return display(fieldname, type, pref, obj, context.getWiki().getCurrentContentSyntaxId(getSyntaxId(), context), |
| 3197 |
|
context); |
| 3198 |
|
} |
| 3199 |
|
|
| 3200 |
|
|
| 3201 |
|
@param |
| 3202 |
|
@param |
| 3203 |
|
@param |
| 3204 |
|
@param |
| 3205 |
|
@param |
| 3206 |
|
|
| 3207 |
|
@param |
| 3208 |
|
@return |
| 3209 |
|
|
| |
|
| 50% |
Uncovered Elements: 53 (106) |
Complexity: 32 |
Complexity Density: 0.5 |
|
| 3210 |
1858 |
public String display(String fieldname, String type, String pref, BaseObject obj, String wrappingSyntaxId,... |
| 3211 |
|
XWikiContext context) |
| 3212 |
|
{ |
| 3213 |
1858 |
if (obj == null) { |
| 3214 |
0 |
return ""; |
| 3215 |
|
} |
| 3216 |
|
|
| 3217 |
1858 |
boolean isInRenderingEngine = BooleanUtils.toBoolean((Boolean) context.get("isInRenderingEngine")); |
| 3218 |
1858 |
HashMap<String, Object> backup = new HashMap<String, Object>(); |
| 3219 |
1858 |
try { |
| 3220 |
1858 |
backupContext(backup, context); |
| 3221 |
1858 |
setAsContextDoc(context); |
| 3222 |
|
|
| 3223 |
|
|
| 3224 |
|
|
| 3225 |
1858 |
XWikiDocument sdoc = context.getDoc(); |
| 3226 |
1858 |
if (sdoc != null && !Objects.equals(sdoc.getContentAuthorReference(), sdoc.getAuthorReference())) { |
| 3227 |
|
|
| 3228 |
24 |
sdoc = sdoc.clone(); |
| 3229 |
24 |
sdoc.setContentAuthorReference(sdoc.getAuthorReference()); |
| 3230 |
24 |
context.put(CKEY_SDOC, sdoc); |
| 3231 |
|
} |
| 3232 |
|
|
| 3233 |
1858 |
type = type.toLowerCase(); |
| 3234 |
1858 |
StringBuffer result = new StringBuffer(); |
| 3235 |
1858 |
PropertyClass pclass = (PropertyClass) obj.getXClass(context).get(fieldname); |
| 3236 |
1858 |
String prefix = pref + LOCAL_REFERENCE_SERIALIZER.serialize(obj.getXClass(context).getDocumentReference()) |
| 3237 |
|
+ "_" + obj.getNumber() + "_"; |
| 3238 |
|
|
| 3239 |
1858 |
if (pclass == null) { |
| 3240 |
0 |
return ""; |
| 3241 |
1858 |
} else if (pclass.isCustomDisplayed(context)) { |
| 3242 |
166 |
pclass.displayCustom(result, fieldname, prefix, type, obj, context); |
| 3243 |
1692 |
} else if (type.equals("view")) { |
| 3244 |
736 |
pclass.displayView(result, fieldname, prefix, obj, context); |
| 3245 |
956 |
} else if (type.equals("rendered")) { |
| 3246 |
0 |
String fcontent = pclass.displayView(fieldname, prefix, obj, context); |
| 3247 |
|
|
| 3248 |
|
|
| 3249 |
|
|
| 3250 |
0 |
if (is10Syntax(wrappingSyntaxId)) { |
| 3251 |
0 |
result.append(getRenderedContent(fcontent, getSyntaxId(), context)); |
| 3252 |
|
} else { |
| 3253 |
0 |
result.append(fcontent); |
| 3254 |
|
} |
| 3255 |
956 |
} else if (type.equals("edit")) { |
| 3256 |
956 |
context.addDisplayedField(fieldname); |
| 3257 |
|
|
| 3258 |
|
|
| 3259 |
|
|
| 3260 |
956 |
if (is10Syntax(wrappingSyntaxId)) { |
| 3261 |
|
|
| 3262 |
1 |
if (isInRenderingEngine) { |
| 3263 |
1 |
result.append("{pre}"); |
| 3264 |
|
} |
| 3265 |
|
} |
| 3266 |
956 |
pclass.displayEdit(result, fieldname, prefix, obj, context); |
| 3267 |
956 |
if (is10Syntax(wrappingSyntaxId)) { |
| 3268 |
1 |
if (isInRenderingEngine) { |
| 3269 |
1 |
result.append("{/pre}"); |
| 3270 |
|
} |
| 3271 |
|
} |
| 3272 |
0 |
} else if (type.equals("hidden")) { |
| 3273 |
|
|
| 3274 |
|
|
| 3275 |
|
|
| 3276 |
0 |
if (is10Syntax(wrappingSyntaxId) && isInRenderingEngine) { |
| 3277 |
0 |
result.append("{pre}"); |
| 3278 |
|
} |
| 3279 |
0 |
pclass.displayHidden(result, fieldname, prefix, obj, context); |
| 3280 |
0 |
if (is10Syntax(wrappingSyntaxId) && isInRenderingEngine) { |
| 3281 |
0 |
result.append("{/pre}"); |
| 3282 |
|
} |
| 3283 |
0 |
} else if (type.equals("search")) { |
| 3284 |
|
|
| 3285 |
|
|
| 3286 |
|
|
| 3287 |
0 |
Method searchMethod = null; |
| 3288 |
0 |
for (Method method : pclass.getClass().getMethods()) { |
| 3289 |
0 |
if (method.getName().equals("displaySearch") && method.getParameterTypes().length == 5) { |
| 3290 |
0 |
searchMethod = method; |
| 3291 |
0 |
break; |
| 3292 |
|
} |
| 3293 |
|
} |
| 3294 |
|
|
| 3295 |
0 |
if (searchMethod != null) { |
| 3296 |
|
|
| 3297 |
|
|
| 3298 |
|
|
| 3299 |
|
|
| 3300 |
0 |
if (is10Syntax(wrappingSyntaxId) && isInRenderingEngine) { |
| 3301 |
0 |
result.append("{pre}"); |
| 3302 |
|
} |
| 3303 |
0 |
prefix = LOCAL_REFERENCE_SERIALIZER.serialize(obj.getXClass(context).getDocumentReference()) + "_"; |
| 3304 |
0 |
searchMethod.invoke(pclass, result, fieldname, prefix, context.get("query"), context); |
| 3305 |
0 |
if (is10Syntax(wrappingSyntaxId) && isInRenderingEngine) { |
| 3306 |
0 |
result.append("{/pre}"); |
| 3307 |
|
} |
| 3308 |
|
} else { |
| 3309 |
0 |
pclass.displayView(result, fieldname, prefix, obj, context); |
| 3310 |
|
} |
| 3311 |
|
} else { |
| 3312 |
0 |
pclass.displayView(result, fieldname, prefix, obj, context); |
| 3313 |
|
} |
| 3314 |
|
|
| 3315 |
|
|
| 3316 |
|
|
| 3317 |
|
|
| 3318 |
|
|
| 3319 |
|
|
| 3320 |
|
|
| 3321 |
|
|
| 3322 |
1858 |
if (isInRenderingEngine && !is10Syntax(wrappingSyntaxId) |
| 3323 |
|
&& (result.indexOf("<") != -1 || result.indexOf(">") != -1)) { |
| 3324 |
381 |
result.insert(0, "{{html clean=\"false\" wiki=\"false\"}}"); |
| 3325 |
381 |
result.append("{{/html}}"); |
| 3326 |
|
} |
| 3327 |
|
|
| 3328 |
1858 |
return result.toString(); |
| 3329 |
|
} catch (Exception ex) { |
| 3330 |
|
|
| 3331 |
|
|
| 3332 |
0 |
LOGGER.warn("Failed to display field [" + fieldname + "] in [" + type + "] mode for Object of Class [" |
| 3333 |
|
+ getDefaultEntityReferenceSerializer().serialize(obj.getDocumentReference()) + "]", ex); |
| 3334 |
0 |
return ""; |
| 3335 |
|
} finally { |
| 3336 |
1858 |
restoreContext(backup, context); |
| 3337 |
|
} |
| 3338 |
|
} |
| 3339 |
|
|
| 3340 |
|
|
| 3341 |
|
@since |
| 3342 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3343 |
0 |
public String displayForm(DocumentReference classReference, String header, String format, XWikiContext context)... |
| 3344 |
|
{ |
| 3345 |
0 |
return displayForm(classReference, header, format, true, context); |
| 3346 |
|
} |
| 3347 |
|
|
| 3348 |
|
|
| 3349 |
|
@deprecated@link |
| 3350 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3351 |
0 |
@Deprecated... |
| 3352 |
|
public String displayForm(String className, String header, String format, XWikiContext context) |
| 3353 |
|
{ |
| 3354 |
0 |
return displayForm(className, header, format, true, context); |
| 3355 |
|
} |
| 3356 |
|
|
| 3357 |
|
|
| 3358 |
|
@since |
| 3359 |
|
|
| |
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 10 |
Complexity Density: 0.33 |
|
| 3360 |
0 |
public String displayForm(DocumentReference classReference, String header, String format, boolean linebreak,... |
| 3361 |
|
XWikiContext context) |
| 3362 |
|
{ |
| 3363 |
0 |
List<BaseObject> objects = getXObjects(classReference); |
| 3364 |
0 |
if (format.endsWith("\\n")) { |
| 3365 |
0 |
linebreak = true; |
| 3366 |
|
} |
| 3367 |
|
|
| 3368 |
0 |
BaseObject firstobject = null; |
| 3369 |
0 |
Iterator<BaseObject> foit = objects.iterator(); |
| 3370 |
0 |
while ((firstobject == null) && foit.hasNext()) { |
| 3371 |
0 |
firstobject = foit.next(); |
| 3372 |
|
} |
| 3373 |
|
|
| 3374 |
0 |
if (firstobject == null) { |
| 3375 |
0 |
return ""; |
| 3376 |
|
} |
| 3377 |
|
|
| 3378 |
0 |
BaseClass bclass = firstobject.getXClass(context); |
| 3379 |
0 |
if (bclass.getPropertyList().size() == 0) { |
| 3380 |
0 |
return ""; |
| 3381 |
|
} |
| 3382 |
|
|
| 3383 |
0 |
StringBuilder result = new StringBuilder(); |
| 3384 |
0 |
VelocityContext vcontext = new VelocityContext(); |
| 3385 |
0 |
for (String propertyName : bclass.getPropertyList()) { |
| 3386 |
0 |
PropertyClass pclass = (PropertyClass) bclass.getField(propertyName); |
| 3387 |
0 |
vcontext.put(pclass.getName(), pclass.getPrettyName()); |
| 3388 |
|
} |
| 3389 |
0 |
result.append(evaluate(header, context.getDoc().getPrefixedFullName(), vcontext, context)); |
| 3390 |
0 |
if (linebreak) { |
| 3391 |
0 |
result.append("\n"); |
| 3392 |
|
} |
| 3393 |
|
|
| 3394 |
|
|
| 3395 |
0 |
for (int i = 0; i < objects.size(); i++) { |
| 3396 |
0 |
vcontext.put("id", Integer.valueOf(i + 1)); |
| 3397 |
0 |
BaseObject object = objects.get(i); |
| 3398 |
0 |
if (object != null) { |
| 3399 |
0 |
for (String name : bclass.getPropertyList()) { |
| 3400 |
0 |
vcontext.put(name, display(name, object, context)); |
| 3401 |
|
} |
| 3402 |
0 |
result.append(evaluate(format, context.getDoc().getPrefixedFullName(), vcontext, context)); |
| 3403 |
0 |
if (linebreak) { |
| 3404 |
0 |
result.append("\n"); |
| 3405 |
|
} |
| 3406 |
|
} |
| 3407 |
|
} |
| 3408 |
0 |
return result.toString(); |
| 3409 |
|
} |
| 3410 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.22 |
|
| 3411 |
0 |
private String evaluate(String content, String name, VelocityContext vcontext, XWikiContext context)... |
| 3412 |
|
{ |
| 3413 |
0 |
StringWriter writer = new StringWriter(); |
| 3414 |
0 |
try { |
| 3415 |
0 |
VelocityManager velocityManager = Utils.getComponent(VelocityManager.class); |
| 3416 |
0 |
velocityManager.getVelocityEngine().evaluate(vcontext, writer, name, content); |
| 3417 |
0 |
return writer.toString(); |
| 3418 |
|
} catch (Exception e) { |
| 3419 |
0 |
LOGGER.error("Error while parsing velocity template namespace [{}]", name, e); |
| 3420 |
0 |
Object[] args = { name }; |
| 3421 |
0 |
XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_RENDERING, |
| 3422 |
|
XWikiException.ERROR_XWIKI_RENDERING_VELOCITY_EXCEPTION, "Error while parsing velocity page {0}", e, |
| 3423 |
|
args); |
| 3424 |
0 |
return Util.getHTMLExceptionMessage(xe, context); |
| 3425 |
|
} |
| 3426 |
|
} |
| 3427 |
|
|
| 3428 |
|
|
| 3429 |
|
@deprecated@link |
| 3430 |
|
|
| 3431 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3432 |
0 |
@Deprecated... |
| 3433 |
|
public String displayForm(String className, String header, String format, boolean linebreak, XWikiContext context) |
| 3434 |
|
{ |
| 3435 |
0 |
return displayForm(resolveClassReference(className), header, format, linebreak, context); |
| 3436 |
|
} |
| 3437 |
|
|
| 3438 |
|
|
| 3439 |
|
@since |
| 3440 |
|
|
| |
|
| 0% |
Uncovered Elements: 57 (57) |
Complexity: 11 |
Complexity Density: 0.28 |
|
| 3441 |
0 |
public String displayForm(DocumentReference classReference, XWikiContext context)... |
| 3442 |
|
{ |
| 3443 |
0 |
List<BaseObject> objects = getXObjects(classReference); |
| 3444 |
0 |
if (objects == null) { |
| 3445 |
0 |
return ""; |
| 3446 |
|
} |
| 3447 |
|
|
| 3448 |
0 |
BaseObject firstobject = null; |
| 3449 |
0 |
Iterator<BaseObject> foit = objects.iterator(); |
| 3450 |
0 |
while ((firstobject == null) && foit.hasNext()) { |
| 3451 |
0 |
firstobject = foit.next(); |
| 3452 |
|
} |
| 3453 |
|
|
| 3454 |
0 |
if (firstobject == null) { |
| 3455 |
0 |
return ""; |
| 3456 |
|
} |
| 3457 |
|
|
| 3458 |
0 |
BaseClass bclass = firstobject.getXClass(context); |
| 3459 |
0 |
if (bclass.getPropertyList().size() == 0) { |
| 3460 |
0 |
return ""; |
| 3461 |
|
} |
| 3462 |
|
|
| 3463 |
0 |
StringBuilder result = new StringBuilder(); |
| 3464 |
0 |
result.append("{table}\n"); |
| 3465 |
0 |
boolean first = true; |
| 3466 |
0 |
for (String propertyName : bclass.getPropertyList()) { |
| 3467 |
0 |
if (first == true) { |
| 3468 |
0 |
first = false; |
| 3469 |
|
} else { |
| 3470 |
0 |
result.append("|"); |
| 3471 |
|
} |
| 3472 |
0 |
PropertyClass pclass = (PropertyClass) bclass.getField(propertyName); |
| 3473 |
0 |
result.append(pclass.getPrettyName()); |
| 3474 |
|
} |
| 3475 |
0 |
result.append("\n"); |
| 3476 |
0 |
for (int i = 0; i < objects.size(); i++) { |
| 3477 |
0 |
BaseObject object = objects.get(i); |
| 3478 |
0 |
if (object != null) { |
| 3479 |
0 |
first = true; |
| 3480 |
0 |
for (String propertyName : bclass.getPropertyList()) { |
| 3481 |
0 |
if (first == true) { |
| 3482 |
0 |
first = false; |
| 3483 |
|
} else { |
| 3484 |
0 |
result.append("|"); |
| 3485 |
|
} |
| 3486 |
0 |
String data = display(propertyName, object, context); |
| 3487 |
0 |
data = data.trim(); |
| 3488 |
0 |
data = data.replaceAll("\n", " "); |
| 3489 |
0 |
if (data.length() == 0) { |
| 3490 |
0 |
result.append(" "); |
| 3491 |
|
} else { |
| 3492 |
0 |
result.append(data); |
| 3493 |
|
} |
| 3494 |
|
} |
| 3495 |
0 |
result.append("\n"); |
| 3496 |
|
} |
| 3497 |
|
} |
| 3498 |
0 |
result.append("{table}\n"); |
| 3499 |
0 |
return result.toString(); |
| 3500 |
|
} |
| 3501 |
|
|
| 3502 |
|
|
| 3503 |
|
@deprecated@link |
| 3504 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3505 |
0 |
@Deprecated... |
| 3506 |
|
public String displayForm(String className, XWikiContext context) |
| 3507 |
|
{ |
| 3508 |
0 |
return displayForm(resolveClassReference(className), context); |
| 3509 |
|
} |
| 3510 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3511 |
31332 |
public boolean isFromCache()... |
| 3512 |
|
{ |
| 3513 |
31330 |
return this.fromCache; |
| 3514 |
|
} |
| 3515 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3516 |
179320 |
public void setFromCache(boolean fromCache)... |
| 3517 |
|
{ |
| 3518 |
179321 |
this.fromCache = fromCache; |
| 3519 |
|
} |
| 3520 |
|
|
| |
|
| 74.4% |
Uncovered Elements: 11 (43) |
Complexity: 12 |
Complexity Density: 0.48 |
|
| 3521 |
271 |
public void readDocMetaFromForm(EditForm eform, XWikiContext context) throws XWikiException... |
| 3522 |
|
{ |
| 3523 |
271 |
String defaultLanguage = eform.getDefaultLanguage(); |
| 3524 |
271 |
if (defaultLanguage != null) { |
| 3525 |
0 |
setDefaultLanguage(defaultLanguage); |
| 3526 |
|
} |
| 3527 |
|
|
| 3528 |
271 |
String defaultTemplate = eform.getDefaultTemplate(); |
| 3529 |
271 |
if (defaultTemplate != null) { |
| 3530 |
0 |
setDefaultTemplate(defaultTemplate); |
| 3531 |
|
} |
| 3532 |
|
|
| 3533 |
271 |
String creator = eform.getCreator(); |
| 3534 |
271 |
if ((creator != null) && (!creator.equals(getCreator()))) { |
| 3535 |
0 |
if ((getCreatorReference().equals(context.getUserReference())) |
| 3536 |
|
|| (context.getWiki().getRightService().hasAdminRights(context))) { |
| 3537 |
0 |
setCreator(creator); |
| 3538 |
|
} |
| 3539 |
|
} |
| 3540 |
|
|
| 3541 |
271 |
String parent = eform.getParent(); |
| 3542 |
271 |
if (parent != null) { |
| 3543 |
90 |
setParent(parent); |
| 3544 |
|
} |
| 3545 |
|
|
| 3546 |
|
|
| 3547 |
271 |
String comment = eform.getComment(); |
| 3548 |
271 |
if (comment != null) { |
| 3549 |
55 |
setComment(comment); |
| 3550 |
|
} |
| 3551 |
|
|
| 3552 |
|
|
| 3553 |
271 |
setMinorEdit(eform.isMinorEdit()); |
| 3554 |
|
|
| 3555 |
271 |
String tags = eform.getTags(); |
| 3556 |
271 |
if (!StringUtils.isEmpty(tags)) { |
| 3557 |
0 |
setTags(tags, context); |
| 3558 |
|
} |
| 3559 |
|
|
| 3560 |
|
|
| 3561 |
271 |
String syntaxId = eform.getSyntaxId(); |
| 3562 |
271 |
if (syntaxId != null) { |
| 3563 |
2 |
setSyntaxId(syntaxId); |
| 3564 |
|
} |
| 3565 |
|
|
| 3566 |
|
|
| 3567 |
271 |
if (eform.getHidden() != null) { |
| 3568 |
3 |
setHidden("1".equals(eform.getHidden())); |
| 3569 |
|
} |
| 3570 |
|
} |
| 3571 |
|
|
| 3572 |
|
|
| 3573 |
|
|
| 3574 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 3575 |
0 |
public void setTags(String tagsStr, XWikiContext context) throws XWikiException... |
| 3576 |
|
{ |
| 3577 |
0 |
BaseClass tagsClass = context.getWiki().getTagClass(context); |
| 3578 |
|
|
| 3579 |
0 |
StaticListClass tagProp = (StaticListClass) tagsClass.getField(XWikiConstant.TAG_CLASS_PROP_TAGS); |
| 3580 |
|
|
| 3581 |
0 |
BaseObject tags = getObject(XWikiConstant.TAG_CLASS, true, context); |
| 3582 |
|
|
| 3583 |
0 |
tags.safeput(XWikiConstant.TAG_CLASS_PROP_TAGS, tagProp.fromString(tagsStr)); |
| 3584 |
|
|
| 3585 |
0 |
setMetaDataDirty(true); |
| 3586 |
|
} |
| 3587 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 3588 |
0 |
public String getTags(XWikiContext context)... |
| 3589 |
|
{ |
| 3590 |
0 |
ListProperty prop = (ListProperty) getTagProperty(context); |
| 3591 |
|
|
| 3592 |
|
|
| 3593 |
|
|
| 3594 |
|
|
| 3595 |
|
|
| 3596 |
0 |
return prop != null ? prop.toFormString() : ""; |
| 3597 |
|
} |
| 3598 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 3599 |
343 |
public List<String> getTagsList(XWikiContext context)... |
| 3600 |
|
{ |
| 3601 |
343 |
List<String> tagList = null; |
| 3602 |
|
|
| 3603 |
343 |
BaseProperty prop = getTagProperty(context); |
| 3604 |
343 |
if (prop != null) { |
| 3605 |
4 |
tagList = (List<String>) prop.getValue(); |
| 3606 |
|
} |
| 3607 |
|
|
| 3608 |
343 |
return tagList; |
| 3609 |
|
} |
| 3610 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 3611 |
343 |
private BaseProperty getTagProperty(XWikiContext context)... |
| 3612 |
|
{ |
| 3613 |
343 |
BaseObject tags = getObject(XWikiConstant.TAG_CLASS); |
| 3614 |
|
|
| 3615 |
343 |
return tags != null ? ((BaseProperty) tags.safeget(XWikiConstant.TAG_CLASS_PROP_TAGS)) : null; |
| 3616 |
|
} |
| 3617 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 3618 |
0 |
public List<String> getTagsPossibleValues(XWikiContext context)... |
| 3619 |
|
{ |
| 3620 |
0 |
List<String> list; |
| 3621 |
|
|
| 3622 |
0 |
try { |
| 3623 |
0 |
BaseClass tagsClass = context.getWiki().getTagClass(context); |
| 3624 |
|
|
| 3625 |
0 |
String possibleValues = |
| 3626 |
|
((StaticListClass) tagsClass.getField(XWikiConstant.TAG_CLASS_PROP_TAGS)).getValues(); |
| 3627 |
|
|
| 3628 |
0 |
return ListClass.getListFromString(possibleValues); |
| 3629 |
|
} catch (XWikiException e) { |
| 3630 |
0 |
LOGGER.error("Failed to get tag class", e); |
| 3631 |
|
|
| 3632 |
0 |
list = Collections.emptyList(); |
| 3633 |
|
} |
| 3634 |
|
|
| 3635 |
0 |
return list; |
| 3636 |
|
} |
| 3637 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 3638 |
142 |
public void readTranslationMetaFromForm(EditForm eform, XWikiContext context) throws XWikiException... |
| 3639 |
|
{ |
| 3640 |
142 |
String content = eform.getContent(); |
| 3641 |
142 |
if (content != null) { |
| 3642 |
|
|
| 3643 |
|
|
| 3644 |
|
|
| 3645 |
70 |
content = context.getUtil().substitute("s/<br class=\"htmlarea\" \\/>/\r\n/g", content); |
| 3646 |
70 |
setContent(content); |
| 3647 |
|
} |
| 3648 |
142 |
String title = eform.getTitle(); |
| 3649 |
142 |
if (title != null) { |
| 3650 |
76 |
setTitle(title); |
| 3651 |
|
} |
| 3652 |
|
} |
| 3653 |
|
|
| |
|
| 95.2% |
Uncovered Elements: 1 (21) |
Complexity: 4 |
Complexity Density: 0.27 |
|
| 3654 |
254 |
public void readObjectsFromForm(EditForm eform, XWikiContext context) throws XWikiException... |
| 3655 |
|
{ |
| 3656 |
254 |
for (DocumentReference reference : getXObjects().keySet()) { |
| 3657 |
158 |
List<BaseObject> oldObjects = getXObjects(reference); |
| 3658 |
158 |
List<BaseObject> newObjects = new ArrayList<BaseObject>(); |
| 3659 |
335 |
while (newObjects.size() < oldObjects.size()) { |
| 3660 |
177 |
newObjects.add(null); |
| 3661 |
|
} |
| 3662 |
335 |
for (int i = 0; i < oldObjects.size(); i++) { |
| 3663 |
177 |
BaseObject oldobject = oldObjects.get(i); |
| 3664 |
177 |
if (oldobject != null) { |
| 3665 |
177 |
BaseClass baseclass = oldobject.getXClass(context); |
| 3666 |
177 |
BaseObject newobject = (BaseObject) baseclass.fromMap( |
| 3667 |
|
eform.getObject( |
| 3668 |
|
LOCAL_REFERENCE_SERIALIZER.serialize(baseclass.getDocumentReference()) + "_" + i), |
| 3669 |
|
oldobject); |
| 3670 |
177 |
newobject.setNumber(oldobject.getNumber()); |
| 3671 |
177 |
newobject.setGuid(oldobject.getGuid()); |
| 3672 |
177 |
newobject.setOwnerDocument(this); |
| 3673 |
177 |
newObjects.set(newobject.getNumber(), newobject); |
| 3674 |
|
} |
| 3675 |
|
} |
| 3676 |
158 |
getXObjects().put(reference, newObjects); |
| 3677 |
|
} |
| 3678 |
|
} |
| 3679 |
|
|
| 3680 |
|
|
| 3681 |
|
|
| 3682 |
|
|
| 3683 |
|
|
| 3684 |
|
|
| 3685 |
|
|
| 3686 |
|
|
| 3687 |
|
|
| 3688 |
|
|
| 3689 |
|
|
| 3690 |
|
|
| 3691 |
|
|
| 3692 |
|
|
| 3693 |
|
|
| 3694 |
|
|
| 3695 |
|
|
| 3696 |
|
|
| 3697 |
|
|
| 3698 |
|
|
| 3699 |
|
|
| 3700 |
|
|
| 3701 |
|
|
| 3702 |
|
|
| 3703 |
|
|
| 3704 |
|
|
| 3705 |
|
|
| 3706 |
|
|
| 3707 |
|
|
| 3708 |
|
|
| 3709 |
|
|
| 3710 |
|
|
| 3711 |
|
|
| 3712 |
|
@param |
| 3713 |
|
@param |
| 3714 |
|
@return |
| 3715 |
|
|
| |
|
| 94.7% |
Uncovered Elements: 2 (38) |
Complexity: 7 |
Complexity Density: 0.23 |
|
| 3716 |
19 |
private Map<DocumentReference, SortedMap<Integer, Map<String, String[]>>> parseRequestUpdateOrCreate(... |
| 3717 |
|
XWikiRequest request, XWikiContext context) |
| 3718 |
|
{ |
| 3719 |
19 |
Map<DocumentReference, SortedMap<Integer, Map<String, String[]>>> result = new HashMap<>(); |
| 3720 |
19 |
@SuppressWarnings("unchecked") |
| 3721 |
|
Map<String, String[]> allParameters = request.getParameterMap(); |
| 3722 |
19 |
for (Entry<String, String[]> parameter : allParameters.entrySet()) { |
| 3723 |
93 |
Matcher matcher = XPROPERTY_REFERENCE_PATTERN.matcher(parameter.getKey()); |
| 3724 |
93 |
if (matcher.matches() == false) { |
| 3725 |
56 |
continue; |
| 3726 |
|
} |
| 3727 |
37 |
Integer classNumber; |
| 3728 |
37 |
String className = matcher.group(1); |
| 3729 |
37 |
String classNumberAsString = matcher.group(2); |
| 3730 |
37 |
String classPropertyName = matcher.group(3); |
| 3731 |
37 |
DocumentReference classReference = getCurrentDocumentReferenceResolver().resolve(className); |
| 3732 |
37 |
try { |
| 3733 |
37 |
BaseClass xClass = context.getWiki().getDocument(classReference, context).getXClass(); |
| 3734 |
37 |
if (xClass.getPropertyList().contains(classPropertyName) == false) { |
| 3735 |
2 |
continue; |
| 3736 |
|
} |
| 3737 |
35 |
classNumber = Integer.parseInt(classNumberAsString); |
| 3738 |
|
} catch (XWikiException e) { |
| 3739 |
|
|
| 3740 |
0 |
LOGGER.warn("Failed to load document [{}], ignoring property update [{}]. Reason: [{}]", classReference, |
| 3741 |
|
parameter.getKey(), ExceptionUtils.getRootCauseMessage(e)); |
| 3742 |
0 |
continue; |
| 3743 |
|
} catch (NumberFormatException e) { |
| 3744 |
|
|
| 3745 |
1 |
LOGGER.warn("Invalid xobject number [{}], ignoring property update [{}].", classNumberAsString, |
| 3746 |
|
parameter.getKey()); |
| 3747 |
1 |
continue; |
| 3748 |
|
} |
| 3749 |
34 |
SortedMap<Integer, Map<String, String[]>> objectMap = result.get(classReference); |
| 3750 |
34 |
if (objectMap == null) { |
| 3751 |
19 |
objectMap = new TreeMap<>(); |
| 3752 |
19 |
result.put(classReference, objectMap); |
| 3753 |
|
} |
| 3754 |
|
|
| 3755 |
34 |
Map<String, String[]> object = objectMap.get(classNumber); |
| 3756 |
34 |
if (object == null) { |
| 3757 |
22 |
object = new HashMap<>(); |
| 3758 |
22 |
objectMap.put(classNumber, object); |
| 3759 |
|
} |
| 3760 |
34 |
object.put(classPropertyName, parameter.getValue()); |
| 3761 |
|
} |
| 3762 |
19 |
return result; |
| 3763 |
|
} |
| 3764 |
|
|
| 3765 |
|
|
| 3766 |
|
|
| 3767 |
|
|
| 3768 |
|
|
| 3769 |
|
|
| 3770 |
|
|
| 3771 |
|
|
| 3772 |
|
|
| 3773 |
|
|
| 3774 |
|
@param |
| 3775 |
|
@param |
| 3776 |
|
@throws |
| 3777 |
|
@since |
| 3778 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 2 (22) |
Complexity: 3 |
Complexity Density: 0.17 |
|
| 3779 |
19 |
public void readObjectsFromFormUpdateOrCreate(EditForm eform, XWikiContext context) throws XWikiException... |
| 3780 |
|
{ |
| 3781 |
19 |
Map<DocumentReference, SortedMap<Integer, Map<String, String[]>>> fromRequest = |
| 3782 |
|
parseRequestUpdateOrCreate(eform.getRequest(), context); |
| 3783 |
19 |
for (Entry<DocumentReference, SortedMap<Integer, Map<String, String[]>>> requestClassEntries : fromRequest |
| 3784 |
|
.entrySet()) { |
| 3785 |
19 |
DocumentReference requestClassReference = requestClassEntries.getKey(); |
| 3786 |
19 |
SortedMap<Integer, Map<String, String[]>> requestObjectMap = requestClassEntries.getValue(); |
| 3787 |
19 |
for (Entry<Integer, Map<String, String[]>> requestObjectEntry : requestObjectMap.entrySet()) { |
| 3788 |
22 |
Integer requestObjectNumber = requestObjectEntry.getKey(); |
| 3789 |
22 |
Map<String, String[]> requestObjectPropertyMap = requestObjectEntry.getValue(); |
| 3790 |
22 |
BaseObject oldObject = getXObject(requestClassReference, requestObjectNumber); |
| 3791 |
22 |
if (oldObject == null) { |
| 3792 |
|
|
| 3793 |
5 |
if (requestObjectPropertyMap != null) { |
| 3794 |
5 |
oldObject = newXObject(requestClassReference, context); |
| 3795 |
|
} else { |
| 3796 |
0 |
break; |
| 3797 |
|
} |
| 3798 |
|
} |
| 3799 |
22 |
BaseClass baseClass = oldObject.getXClass(context); |
| 3800 |
22 |
BaseObject newObject = (BaseObject) baseClass.fromMap(requestObjectPropertyMap, oldObject); |
| 3801 |
22 |
newObject.setNumber(oldObject.getNumber()); |
| 3802 |
22 |
newObject.setGuid(oldObject.getGuid()); |
| 3803 |
22 |
newObject.setOwnerDocument(this); |
| 3804 |
22 |
setXObject(requestObjectNumber, newObject); |
| 3805 |
|
} |
| 3806 |
|
} |
| 3807 |
|
} |
| 3808 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 3809 |
142 |
public void readFromForm(EditForm eform, XWikiContext context) throws XWikiException... |
| 3810 |
|
{ |
| 3811 |
142 |
readDocMetaFromForm(eform, context); |
| 3812 |
142 |
readTranslationMetaFromForm(eform, context); |
| 3813 |
142 |
ObjectPolicyType objectPolicy = eform.getObjectPolicy(); |
| 3814 |
142 |
if (objectPolicy == null || objectPolicy.equals(ObjectPolicyType.UPDATE)) { |
| 3815 |
124 |
readObjectsFromForm(eform, context); |
| 3816 |
18 |
} else if (objectPolicy.equals(ObjectPolicyType.UPDATE_OR_CREATE)) { |
| 3817 |
18 |
readObjectsFromFormUpdateOrCreate(eform, context); |
| 3818 |
|
} |
| 3819 |
|
} |
| 3820 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 3821 |
279 |
public void readFromTemplate(EditForm eform, XWikiContext context) throws XWikiException... |
| 3822 |
|
{ |
| 3823 |
279 |
String template = eform.getTemplate(); |
| 3824 |
279 |
readFromTemplate(template, context); |
| 3825 |
|
} |
| 3826 |
|
|
| 3827 |
|
|
| 3828 |
|
@since |
| 3829 |
|
|
| |
|
| 76.7% |
Uncovered Elements: 7 (30) |
Complexity: 8 |
Complexity Density: 0.4 |
|
| 3830 |
420 |
public void readFromTemplate(DocumentReference templateDocumentReference, XWikiContext context)... |
| 3831 |
|
throws XWikiException |
| 3832 |
|
{ |
| 3833 |
420 |
if (templateDocumentReference != null) { |
| 3834 |
34 |
String content = getContent(); |
| 3835 |
34 |
if (!content.equals("\n") && !content.equals("") && !isNew()) { |
| 3836 |
0 |
Object[] args = { getDefaultEntityReferenceSerializer().serialize(getDocumentReference()) }; |
| 3837 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, |
| 3838 |
|
XWikiException.ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY, |
| 3839 |
|
"Cannot add a template to document {0} because it already has content", null, args); |
| 3840 |
|
} else { |
| 3841 |
34 |
XWiki xwiki = context.getWiki(); |
| 3842 |
34 |
XWikiDocument templatedoc = xwiki.getDocument(templateDocumentReference, context); |
| 3843 |
34 |
if (templatedoc.isNew()) { |
| 3844 |
0 |
Object[] args = { getDefaultEntityReferenceSerializer().serialize(templateDocumentReference), |
| 3845 |
|
getCompactEntityReferenceSerializer().serialize(getDocumentReference()) }; |
| 3846 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, |
| 3847 |
|
XWikiException.ERROR_XWIKI_APP_TEMPLATE_DOES_NOT_EXIST, |
| 3848 |
|
"Template document {0} does not exist when adding to document {1}", null, args); |
| 3849 |
|
} else { |
| 3850 |
34 |
setTemplateDocumentReference(templateDocumentReference); |
| 3851 |
34 |
setTitle(templatedoc.getTitle()); |
| 3852 |
34 |
setContent(templatedoc.getContent()); |
| 3853 |
|
|
| 3854 |
|
|
| 3855 |
|
|
| 3856 |
34 |
setSyntax(templatedoc.getSyntax()); |
| 3857 |
|
|
| 3858 |
|
|
| 3859 |
34 |
if (getParentReference() == null) { |
| 3860 |
20 |
setParentReference(templatedoc.getRelativeParentReference()); |
| 3861 |
|
} |
| 3862 |
|
|
| 3863 |
34 |
if (isNew()) { |
| 3864 |
|
|
| 3865 |
|
|
| 3866 |
34 |
setXObjects(new TreeMap<DocumentReference, List<BaseObject>>()); |
| 3867 |
|
} |
| 3868 |
|
|
| 3869 |
|
|
| 3870 |
|
|
| 3871 |
34 |
mergeXObjects(templatedoc); |
| 3872 |
|
|
| 3873 |
|
|
| 3874 |
34 |
copyAttachments(templatedoc); |
| 3875 |
|
} |
| 3876 |
|
} |
| 3877 |
|
} |
| 3878 |
|
} |
| 3879 |
|
|
| 3880 |
|
|
| 3881 |
|
@deprecated@link |
| 3882 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 3883 |
417 |
@Deprecated... |
| 3884 |
|
public void readFromTemplate(String template, XWikiContext context) throws XWikiException |
| 3885 |
|
{ |
| 3886 |
|
|
| 3887 |
417 |
DocumentReference templateDocumentReference = null; |
| 3888 |
417 |
if (StringUtils.isNotEmpty(template)) { |
| 3889 |
31 |
templateDocumentReference = getCurrentMixedDocumentReferenceResolver().resolve(template); |
| 3890 |
|
} |
| 3891 |
417 |
readFromTemplate(templateDocumentReference, context); |
| 3892 |
|
} |
| 3893 |
|
|
| 3894 |
|
|
| 3895 |
|
|
| 3896 |
|
|
| 3897 |
|
@param |
| 3898 |
|
@throws |
| 3899 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (38) |
Complexity: 1 |
Complexity Density: 0.03 |
|
| 3900 |
5 |
private void clone(XWikiDocument document)... |
| 3901 |
|
{ |
| 3902 |
5 |
this.id = document.id; |
| 3903 |
|
|
| 3904 |
5 |
setDocumentReference(document.getDocumentReference()); |
| 3905 |
5 |
setRCSVersion(document.getRCSVersion()); |
| 3906 |
5 |
setDocumentArchive(document.getDocumentArchive()); |
| 3907 |
5 |
setAuthorReference(document.getAuthorReference()); |
| 3908 |
5 |
setContentAuthorReference(document.getContentAuthorReference()); |
| 3909 |
5 |
setContent(document.getContent()); |
| 3910 |
5 |
setCreationDate(document.getCreationDate()); |
| 3911 |
5 |
setDate(document.getDate()); |
| 3912 |
5 |
setCustomClass(document.getCustomClass()); |
| 3913 |
5 |
setContentUpdateDate(document.getContentUpdateDate()); |
| 3914 |
5 |
setTitle(document.getTitle()); |
| 3915 |
5 |
setFormat(document.getFormat()); |
| 3916 |
5 |
setFromCache(document.isFromCache()); |
| 3917 |
5 |
setElements(document.getElements()); |
| 3918 |
5 |
setMeta(document.getMeta()); |
| 3919 |
5 |
setMostRecent(document.isMostRecent()); |
| 3920 |
5 |
setNew(document.isNew()); |
| 3921 |
5 |
setStore(document.getStore()); |
| 3922 |
5 |
setTemplateDocumentReference(document.getTemplateDocumentReference()); |
| 3923 |
5 |
setParentReference(document.getRelativeParentReference()); |
| 3924 |
5 |
setCreatorReference(document.getCreatorReference()); |
| 3925 |
5 |
setDefaultLocale(document.getDefaultLocale()); |
| 3926 |
5 |
setDefaultTemplate(document.getDefaultTemplate()); |
| 3927 |
5 |
setValidationScript(document.getValidationScript()); |
| 3928 |
5 |
setLocale(document.getLocale()); |
| 3929 |
5 |
setXClass(document.getXClass().clone()); |
| 3930 |
5 |
setXClassXML(document.getXClassXML()); |
| 3931 |
5 |
setComment(document.getComment()); |
| 3932 |
5 |
setMinorEdit(document.isMinorEdit()); |
| 3933 |
5 |
setSyntax(document.getSyntax()); |
| 3934 |
5 |
setHidden(document.isHidden()); |
| 3935 |
|
|
| 3936 |
5 |
cloneXObjects(document); |
| 3937 |
5 |
cloneAttachments(document); |
| 3938 |
|
|
| 3939 |
5 |
setContentDirty(document.isContentDirty()); |
| 3940 |
5 |
setMetaDataDirty(document.isMetaDataDirty()); |
| 3941 |
|
|
| 3942 |
5 |
this.elements = document.elements; |
| 3943 |
|
|
| 3944 |
5 |
this.originalDocument = document.originalDocument; |
| 3945 |
|
} |
| 3946 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3947 |
31197 |
@Override... |
| 3948 |
|
public XWikiDocument clone() |
| 3949 |
|
{ |
| 3950 |
31196 |
return cloneInternal(getDocumentReference(), true); |
| 3951 |
|
} |
| 3952 |
|
|
| 3953 |
|
|
| 3954 |
|
|
| 3955 |
|
|
| 3956 |
|
@since |
| 3957 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 3958 |
131 |
public XWikiDocument duplicate(DocumentReference newDocumentReference)... |
| 3959 |
|
{ |
| 3960 |
131 |
return cloneInternal(newDocumentReference, false); |
| 3961 |
|
} |
| 3962 |
|
|
| |
|
| 98.1% |
Uncovered Elements: 1 (52) |
Complexity: 4 |
Complexity Density: 0.08 |
|
| 3963 |
31321 |
private XWikiDocument cloneInternal(DocumentReference newDocumentReference, boolean keepsIdentity)... |
| 3964 |
|
{ |
| 3965 |
31322 |
XWikiDocument doc = null; |
| 3966 |
31324 |
try { |
| 3967 |
31321 |
Constructor<? extends XWikiDocument> constructor = getClass().getConstructor(DocumentReference.class); |
| 3968 |
31326 |
doc = constructor.newInstance(newDocumentReference); |
| 3969 |
|
|
| 3970 |
|
|
| 3971 |
31325 |
doc.version = this.version; |
| 3972 |
31326 |
doc.id = this.id; |
| 3973 |
31324 |
doc.setDocumentArchive(getDocumentArchive()); |
| 3974 |
31326 |
doc.setAuthorReference(getAuthorReference()); |
| 3975 |
31326 |
doc.setContentAuthorReference(getContentAuthorReference()); |
| 3976 |
31326 |
doc.setContent(getContent()); |
| 3977 |
31327 |
doc.setCreationDate(getCreationDate()); |
| 3978 |
31324 |
doc.setDate(getDate()); |
| 3979 |
31325 |
doc.setCustomClass(getCustomClass()); |
| 3980 |
31327 |
doc.setContentUpdateDate(getContentUpdateDate()); |
| 3981 |
31324 |
doc.setTitle(getTitle()); |
| 3982 |
31327 |
doc.setFormat(getFormat()); |
| 3983 |
31327 |
doc.setFromCache(isFromCache()); |
| 3984 |
31323 |
doc.setElements(getElements()); |
| 3985 |
31327 |
doc.setMeta(getMeta()); |
| 3986 |
31319 |
doc.setMostRecent(isMostRecent()); |
| 3987 |
31328 |
doc.setNew(isNew()); |
| 3988 |
31323 |
doc.setStore(getStore()); |
| 3989 |
31323 |
doc.setTemplateDocumentReference(getTemplateDocumentReference()); |
| 3990 |
31323 |
doc.setParentReference(getRelativeParentReference()); |
| 3991 |
31319 |
doc.setCreatorReference(getCreatorReference()); |
| 3992 |
31327 |
doc.setDefaultLocale(getDefaultLocale()); |
| 3993 |
31325 |
doc.setDefaultTemplate(getDefaultTemplate()); |
| 3994 |
31320 |
doc.setValidationScript(getValidationScript()); |
| 3995 |
31321 |
doc.setLocale(getLocale()); |
| 3996 |
31325 |
doc.setComment(getComment()); |
| 3997 |
31326 |
doc.setMinorEdit(isMinorEdit()); |
| 3998 |
31327 |
doc.setSyntax(getSyntax()); |
| 3999 |
31324 |
doc.setHidden(isHidden()); |
| 4000 |
|
|
| 4001 |
31322 |
if (this.xClass != null) { |
| 4002 |
20722 |
doc.setXClass(this.xClass.clone()); |
| 4003 |
|
} |
| 4004 |
|
|
| 4005 |
31323 |
if (keepsIdentity) { |
| 4006 |
31187 |
doc.setXClassXML(getXClassXML()); |
| 4007 |
31196 |
doc.cloneXObjects(this); |
| 4008 |
31191 |
doc.cloneAttachments(this); |
| 4009 |
|
} else { |
| 4010 |
131 |
doc.getXClass().setCustomMapping(null); |
| 4011 |
131 |
doc.duplicateXObjects(this); |
| 4012 |
131 |
doc.copyAttachments(this); |
| 4013 |
|
} |
| 4014 |
|
|
| 4015 |
31322 |
doc.setContentDirty(isContentDirty()); |
| 4016 |
31321 |
doc.setMetaDataDirty(isMetaDataDirty()); |
| 4017 |
|
|
| 4018 |
31322 |
doc.elements = this.elements; |
| 4019 |
|
|
| 4020 |
31322 |
doc.originalDocument = this.originalDocument; |
| 4021 |
|
} catch (Exception e) { |
| 4022 |
|
|
| 4023 |
0 |
LOGGER.error("Exception while cloning document", e); |
| 4024 |
|
} |
| 4025 |
31321 |
return doc; |
| 4026 |
|
} |
| 4027 |
|
|
| 4028 |
|
|
| 4029 |
|
|
| 4030 |
|
|
| 4031 |
|
|
| 4032 |
|
@param |
| 4033 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 4034 |
31198 |
private void cloneAttachments(final XWikiDocument sourceDocument)... |
| 4035 |
|
{ |
| 4036 |
31200 |
this.getAttachmentList().clear(); |
| 4037 |
31196 |
for (XWikiAttachment attach : sourceDocument.getAttachmentList()) { |
| 4038 |
56419 |
XWikiAttachment newAttach = (XWikiAttachment) attach.clone(); |
| 4039 |
|
|
| 4040 |
|
|
| 4041 |
|
|
| 4042 |
56419 |
newAttach.setDoc(this); |
| 4043 |
|
|
| 4044 |
56419 |
this.getAttachmentList().add(newAttach); |
| 4045 |
|
} |
| 4046 |
|
} |
| 4047 |
|
|
| 4048 |
|
|
| 4049 |
|
|
| 4050 |
|
|
| 4051 |
|
|
| 4052 |
|
@param |
| 4053 |
|
|
| |
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 4054 |
165 |
public void copyAttachments(XWikiDocument sourceDocument)... |
| 4055 |
|
{ |
| 4056 |
|
|
| 4057 |
165 |
getAttachmentList().clear(); |
| 4058 |
|
|
| 4059 |
165 |
Iterator<XWikiAttachment> attit = sourceDocument.getAttachmentList().iterator(); |
| 4060 |
166 |
while (attit.hasNext()) { |
| 4061 |
1 |
XWikiAttachment attachment = attit.next(); |
| 4062 |
1 |
XWikiAttachment newattachment = (XWikiAttachment) attachment.clone(); |
| 4063 |
1 |
newattachment.setDoc(this); |
| 4064 |
|
|
| 4065 |
|
|
| 4066 |
|
|
| 4067 |
|
|
| 4068 |
|
|
| 4069 |
1 |
if (newattachment.getAttachment_content() != null) { |
| 4070 |
1 |
newattachment.getAttachment_content().setContentDirty(true); |
| 4071 |
|
} |
| 4072 |
|
|
| 4073 |
1 |
getAttachmentList().add(newattachment); |
| 4074 |
|
} |
| 4075 |
|
} |
| 4076 |
|
|
| 4077 |
|
|
| 4078 |
|
|
| 4079 |
|
|
| 4080 |
|
@param |
| 4081 |
|
@throws |
| 4082 |
|
@since |
| 4083 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 4084 |
458 |
public void loadAttachmentsContent(XWikiContext context) throws XWikiException... |
| 4085 |
|
{ |
| 4086 |
458 |
for (XWikiAttachment attachment : getAttachmentList()) { |
| 4087 |
21 |
attachment.loadContent(context); |
| 4088 |
|
} |
| 4089 |
|
} |
| 4090 |
|
|
| |
|
| 33.3% |
Uncovered Elements: 2 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 4091 |
126 |
public void loadAttachments(XWikiContext context) throws XWikiException... |
| 4092 |
|
{ |
| 4093 |
126 |
for (XWikiAttachment attachment : getAttachmentList()) { |
| 4094 |
0 |
attachment.loadContent(context); |
| 4095 |
0 |
attachment.loadArchive(context); |
| 4096 |
|
} |
| 4097 |
|
} |
| 4098 |
|
|
| |
|
| 61.3% |
Uncovered Elements: 24 (62) |
Complexity: 16 |
Complexity Density: 0.5 |
|
| 4099 |
12 |
@Override... |
| 4100 |
|
public boolean equals(Object object) |
| 4101 |
|
{ |
| 4102 |
|
|
| 4103 |
12 |
if (this == object) { |
| 4104 |
6 |
return true; |
| 4105 |
|
} |
| 4106 |
|
|
| 4107 |
|
|
| 4108 |
|
|
| 4109 |
6 |
XWikiDocument doc = (XWikiDocument) object; |
| 4110 |
6 |
if (!getDocumentReference().equals(doc.getDocumentReference())) { |
| 4111 |
0 |
return false; |
| 4112 |
|
} |
| 4113 |
|
|
| 4114 |
6 |
if (!getDefaultLocale().equals(doc.getDefaultLocale())) { |
| 4115 |
0 |
return false; |
| 4116 |
|
} |
| 4117 |
|
|
| 4118 |
6 |
if (!getLocale().equals(doc.getLocale())) { |
| 4119 |
0 |
return false; |
| 4120 |
|
} |
| 4121 |
|
|
| 4122 |
6 |
if (getTranslation() != doc.getTranslation()) { |
| 4123 |
0 |
return false; |
| 4124 |
|
} |
| 4125 |
|
|
| 4126 |
|
|
| 4127 |
|
|
| 4128 |
6 |
if (ObjectUtils.notEqual(getAuthorReference(), doc.getAuthorReference())) { |
| 4129 |
1 |
return false; |
| 4130 |
|
} |
| 4131 |
|
|
| 4132 |
5 |
if (ObjectUtils.notEqual(getContentAuthorReference(), doc.getContentAuthorReference())) { |
| 4133 |
0 |
return false; |
| 4134 |
|
} |
| 4135 |
|
|
| 4136 |
5 |
if (ObjectUtils.notEqual(getCreatorReference(), doc.getCreatorReference())) { |
| 4137 |
0 |
return false; |
| 4138 |
|
} |
| 4139 |
|
|
| 4140 |
|
|
| 4141 |
|
|
| 4142 |
5 |
if (!getVersion().equals(doc.getVersion())) { |
| 4143 |
0 |
return false; |
| 4144 |
|
} |
| 4145 |
|
|
| 4146 |
5 |
if (getDate().getTime() != doc.getDate().getTime()) { |
| 4147 |
0 |
return false; |
| 4148 |
|
} |
| 4149 |
|
|
| 4150 |
5 |
if (getContentUpdateDate().getTime() != doc.getContentUpdateDate().getTime()) { |
| 4151 |
0 |
return false; |
| 4152 |
|
} |
| 4153 |
|
|
| 4154 |
5 |
if (getCreationDate().getTime() != doc.getCreationDate().getTime()) { |
| 4155 |
0 |
return false; |
| 4156 |
|
} |
| 4157 |
|
|
| 4158 |
5 |
if (!getComment().equals(doc.getComment())) { |
| 4159 |
0 |
return false; |
| 4160 |
|
} |
| 4161 |
|
|
| 4162 |
5 |
if (isMinorEdit() != doc.isMinorEdit()) { |
| 4163 |
0 |
return false; |
| 4164 |
|
} |
| 4165 |
|
|
| 4166 |
|
|
| 4167 |
|
|
| 4168 |
5 |
if (!equalsData(doc)) { |
| 4169 |
1 |
return false; |
| 4170 |
|
} |
| 4171 |
|
|
| 4172 |
|
|
| 4173 |
|
|
| 4174 |
|
|
| 4175 |
|
|
| 4176 |
4 |
return true; |
| 4177 |
|
} |
| 4178 |
|
|
| 4179 |
|
|
| 4180 |
|
@link |
| 4181 |
|
|
| 4182 |
|
|
| 4183 |
|
|
| 4184 |
|
|
| 4185 |
|
|
| 4186 |
|
@param |
| 4187 |
|
@return |
| 4188 |
|
@since |
| 4189 |
|
|
| |
|
| 67.5% |
Uncovered Elements: 27 (83) |
Complexity: 25 |
Complexity Density: 0.53 |
|
| 4190 |
106 |
public boolean equalsData(XWikiDocument otherDocument)... |
| 4191 |
|
{ |
| 4192 |
|
|
| 4193 |
106 |
if (this == otherDocument) { |
| 4194 |
0 |
return true; |
| 4195 |
|
} |
| 4196 |
|
|
| 4197 |
106 |
if (ObjectUtils.notEqual(getParentReference(), otherDocument.getParentReference())) { |
| 4198 |
0 |
return false; |
| 4199 |
|
} |
| 4200 |
|
|
| 4201 |
106 |
if (!getFormat().equals(otherDocument.getFormat())) { |
| 4202 |
0 |
return false; |
| 4203 |
|
} |
| 4204 |
|
|
| 4205 |
106 |
if (!getTitle().equals(otherDocument.getTitle())) { |
| 4206 |
0 |
return false; |
| 4207 |
|
} |
| 4208 |
|
|
| 4209 |
106 |
if (!getContent().equals(otherDocument.getContent())) { |
| 4210 |
5 |
return false; |
| 4211 |
|
} |
| 4212 |
|
|
| 4213 |
101 |
if (!getDefaultTemplate().equals(otherDocument.getDefaultTemplate())) { |
| 4214 |
0 |
return false; |
| 4215 |
|
} |
| 4216 |
|
|
| 4217 |
101 |
if (!getValidationScript().equals(otherDocument.getValidationScript())) { |
| 4218 |
0 |
return false; |
| 4219 |
|
} |
| 4220 |
|
|
| 4221 |
101 |
if (ObjectUtils.notEqual(getSyntax(), otherDocument.getSyntax())) { |
| 4222 |
0 |
return false; |
| 4223 |
|
} |
| 4224 |
|
|
| 4225 |
101 |
if (isHidden() != otherDocument.isHidden()) { |
| 4226 |
0 |
return false; |
| 4227 |
|
} |
| 4228 |
|
|
| 4229 |
|
|
| 4230 |
|
|
| 4231 |
101 |
if (!getXClass().equals(otherDocument.getXClass())) { |
| 4232 |
20 |
return false; |
| 4233 |
|
} |
| 4234 |
|
|
| 4235 |
|
|
| 4236 |
|
|
| 4237 |
81 |
Set<DocumentReference> myObjectClassReferences = getXObjects().keySet(); |
| 4238 |
81 |
Set<DocumentReference> otherObjectClassReferences = otherDocument.getXObjects().keySet(); |
| 4239 |
81 |
if (!myObjectClassReferences.equals(otherObjectClassReferences)) { |
| 4240 |
0 |
return false; |
| 4241 |
|
} |
| 4242 |
|
|
| 4243 |
81 |
for (DocumentReference reference : myObjectClassReferences) { |
| 4244 |
20 |
List<BaseObject> myObjects = getXObjects(reference); |
| 4245 |
20 |
List<BaseObject> otherObjects = otherDocument.getXObjects(reference); |
| 4246 |
20 |
if (myObjects.size() != otherObjects.size()) { |
| 4247 |
0 |
return false; |
| 4248 |
|
} |
| 4249 |
45 |
for (int i = 0; i < myObjects.size(); i++) { |
| 4250 |
25 |
if ((myObjects.get(i) == null && otherObjects.get(i) != null) |
| 4251 |
|
|| (myObjects.get(i) != null && otherObjects.get(i) == null)) { |
| 4252 |
0 |
return false; |
| 4253 |
|
} |
| 4254 |
25 |
if (myObjects.get(i) == null && otherObjects.get(i) == null) { |
| 4255 |
4 |
continue; |
| 4256 |
|
} |
| 4257 |
21 |
if (!myObjects.get(i).equals(otherObjects.get(i))) { |
| 4258 |
0 |
return false; |
| 4259 |
|
} |
| 4260 |
|
} |
| 4261 |
|
} |
| 4262 |
|
|
| 4263 |
|
|
| 4264 |
81 |
List<XWikiAttachment> attachments = getAttachmentList(); |
| 4265 |
81 |
List<XWikiAttachment> otherAttachments = otherDocument.getAttachmentList(); |
| 4266 |
81 |
if (attachments.size() != otherAttachments.size()) { |
| 4267 |
0 |
return false; |
| 4268 |
|
} |
| 4269 |
81 |
for (XWikiAttachment attachment : attachments) { |
| 4270 |
5 |
XWikiAttachment otherAttachment = otherDocument.getAttachment(attachment.getFilename()); |
| 4271 |
5 |
try { |
| 4272 |
5 |
if (otherAttachment == null || !attachment.equalsData(otherAttachment, null)) { |
| 4273 |
2 |
return false; |
| 4274 |
|
} |
| 4275 |
|
} catch (XWikiException e) { |
| 4276 |
0 |
throw new RuntimeException( |
| 4277 |
|
String.format("Failed to compare attachments with reference [%s]", attachment.getReference()), e); |
| 4278 |
|
} |
| 4279 |
|
} |
| 4280 |
|
|
| 4281 |
79 |
return true; |
| 4282 |
|
} |
| 4283 |
|
|
| 4284 |
|
|
| 4285 |
|
|
| 4286 |
|
|
| 4287 |
|
|
| 4288 |
|
|
| 4289 |
|
|
| 4290 |
|
@param |
| 4291 |
|
@return |
| 4292 |
|
@throws |
| 4293 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 4294 |
0 |
public String getXMLContent(XWikiContext context) throws XWikiException... |
| 4295 |
|
{ |
| 4296 |
0 |
XWikiDocument tdoc = getTranslatedDocument(context); |
| 4297 |
0 |
return tdoc.toXML(true, true, false, false, context); |
| 4298 |
|
} |
| 4299 |
|
|
| 4300 |
|
|
| 4301 |
|
|
| 4302 |
|
|
| 4303 |
|
|
| 4304 |
|
|
| 4305 |
|
@param |
| 4306 |
|
@return |
| 4307 |
|
@throws |
| 4308 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4309 |
6138 |
public String toXML(XWikiContext context) throws XWikiException... |
| 4310 |
|
{ |
| 4311 |
6138 |
return toXML(true, false, false, false, context); |
| 4312 |
|
} |
| 4313 |
|
|
| 4314 |
|
|
| 4315 |
|
|
| 4316 |
|
|
| 4317 |
|
|
| 4318 |
|
|
| 4319 |
|
@param |
| 4320 |
|
@return |
| 4321 |
|
@throws |
| 4322 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4323 |
153 |
public String toFullXML(XWikiContext context) throws XWikiException... |
| 4324 |
|
{ |
| 4325 |
153 |
return toXML(true, false, true, true, context); |
| 4326 |
|
} |
| 4327 |
|
|
| 4328 |
|
|
| 4329 |
|
|
| 4330 |
|
|
| 4331 |
|
|
| 4332 |
|
@param |
| 4333 |
|
@param |
| 4334 |
|
@param |
| 4335 |
|
@param |
| 4336 |
|
@throws |
| 4337 |
|
@throws |
| 4338 |
|
@since |
| 4339 |
|
@deprecated |
| 4340 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 4341 |
0 |
@Deprecated... |
| 4342 |
|
public void addToZip(ZipOutputStream zos, String zipname, boolean withVersions, XWikiContext context) |
| 4343 |
|
throws XWikiException, IOException |
| 4344 |
|
{ |
| 4345 |
0 |
ZipEntry zipentry = new ZipEntry(zipname); |
| 4346 |
0 |
zos.putNextEntry(zipentry); |
| 4347 |
0 |
toXML(zos, true, false, true, withVersions, context); |
| 4348 |
0 |
zos.closeEntry(); |
| 4349 |
|
} |
| 4350 |
|
|
| 4351 |
|
|
| 4352 |
|
|
| 4353 |
|
|
| 4354 |
|
|
| 4355 |
|
@param |
| 4356 |
|
@param |
| 4357 |
|
@param |
| 4358 |
|
@throws |
| 4359 |
|
@throws |
| 4360 |
|
@since |
| 4361 |
|
@deprecated |
| 4362 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 4363 |
0 |
@Deprecated... |
| 4364 |
|
public void addToZip(ZipOutputStream zos, boolean withVersions, XWikiContext context) |
| 4365 |
|
throws XWikiException, IOException |
| 4366 |
|
{ |
| 4367 |
0 |
String zipname = |
| 4368 |
|
getDocumentReference().getLastSpaceReference().getName() + "/" + getDocumentReference().getName(); |
| 4369 |
0 |
String language = getLanguage(); |
| 4370 |
0 |
if (!StringUtils.isEmpty(language)) { |
| 4371 |
0 |
zipname += "." + language; |
| 4372 |
|
} |
| 4373 |
0 |
addToZip(zos, zipname, withVersions, context); |
| 4374 |
|
} |
| 4375 |
|
|
| 4376 |
|
|
| 4377 |
|
|
| 4378 |
|
|
| 4379 |
|
|
| 4380 |
|
|
| 4381 |
|
@param |
| 4382 |
|
@param |
| 4383 |
|
@throws |
| 4384 |
|
@throws |
| 4385 |
|
@since |
| 4386 |
|
@deprecated |
| 4387 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4388 |
0 |
@Deprecated... |
| 4389 |
|
public void addToZip(ZipOutputStream zos, XWikiContext context) throws XWikiException, IOException |
| 4390 |
|
{ |
| 4391 |
0 |
addToZip(zos, true, context); |
| 4392 |
|
} |
| 4393 |
|
|
| 4394 |
|
|
| 4395 |
|
|
| 4396 |
|
@link |
| 4397 |
|
@link |
| 4398 |
|
|
| 4399 |
|
|
| 4400 |
|
@param |
| 4401 |
|
@param |
| 4402 |
|
@param |
| 4403 |
|
@param |
| 4404 |
|
@param |
| 4405 |
|
@return |
| 4406 |
|
@throws |
| 4407 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 4408 |
6306 |
public String toXML(boolean bWithObjects, boolean bWithRendering, boolean bWithAttachmentContent,... |
| 4409 |
|
boolean bWithVersions, XWikiContext context) throws XWikiException |
| 4410 |
|
{ |
| 4411 |
6306 |
StringWriter writer = new StringWriter(); |
| 4412 |
6306 |
toXML(new DefaultWriterOutputTarget(writer), bWithObjects, bWithRendering, bWithAttachmentContent, |
| 4413 |
|
bWithVersions, context); |
| 4414 |
6306 |
return writer.toString(); |
| 4415 |
|
} |
| 4416 |
|
|
| 4417 |
|
|
| 4418 |
|
@link |
| 4419 |
|
|
| 4420 |
|
|
| 4421 |
|
|
| 4422 |
|
@param |
| 4423 |
|
@return@link |
| 4424 |
|
@throws |
| 4425 |
|
@deprecated@link |
| 4426 |
|
|
| 4427 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4428 |
1 |
@Deprecated... |
| 4429 |
|
public Document toXMLDocument(XWikiContext context) throws XWikiException |
| 4430 |
|
{ |
| 4431 |
1 |
return toXMLDocument(true, false, false, false, context); |
| 4432 |
|
} |
| 4433 |
|
|
| 4434 |
|
|
| 4435 |
|
@link |
| 4436 |
|
@link |
| 4437 |
|
@link |
| 4438 |
|
|
| 4439 |
|
|
| 4440 |
|
@param |
| 4441 |
|
@param |
| 4442 |
|
@param |
| 4443 |
|
@param |
| 4444 |
|
@param |
| 4445 |
|
@return@link |
| 4446 |
|
@throws |
| 4447 |
|
@deprecated@link |
| 4448 |
|
|
| 4449 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 4450 |
1 |
@Deprecated... |
| 4451 |
|
public Document toXMLDocument(boolean bWithObjects, boolean bWithRendering, boolean bWithAttachmentContent, |
| 4452 |
|
boolean bWithVersions, XWikiContext context) throws XWikiException |
| 4453 |
|
{ |
| 4454 |
1 |
Document doc = new DOMDocument(); |
| 4455 |
1 |
DOMXMLWriter wr = new DOMXMLWriter(doc, new OutputFormat("", true, context.getWiki().getEncoding())); |
| 4456 |
|
|
| 4457 |
1 |
try { |
| 4458 |
1 |
toXML(wr, bWithObjects, bWithRendering, bWithAttachmentContent, bWithVersions, context); |
| 4459 |
1 |
return doc; |
| 4460 |
|
} catch (IOException e) { |
| 4461 |
0 |
throw new RuntimeException(e); |
| 4462 |
|
} |
| 4463 |
|
} |
| 4464 |
|
|
| 4465 |
|
|
| 4466 |
|
@link |
| 4467 |
|
|
| 4468 |
|
@param |
| 4469 |
|
@param |
| 4470 |
|
@param |
| 4471 |
|
@param |
| 4472 |
|
@param |
| 4473 |
|
@throws |
| 4474 |
|
@throws |
| 4475 |
|
@since |
| 4476 |
|
@deprecated@link |
| 4477 |
|
|
| 4478 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 4479 |
1 |
@Deprecated... |
| 4480 |
|
public void toXML(XMLWriter wr, boolean bWithObjects, boolean bWithRendering, boolean bWithAttachmentContent, |
| 4481 |
|
boolean bWithVersions, XWikiContext context) throws XWikiException, IOException |
| 4482 |
|
{ |
| 4483 |
|
|
| 4484 |
1 |
DocumentResult domResult = new DocumentResult(); |
| 4485 |
|
|
| 4486 |
1 |
toXML(new DefaultResultOutputTarget(domResult), bWithObjects, bWithRendering, bWithAttachmentContent, |
| 4487 |
|
bWithVersions, context); |
| 4488 |
|
|
| 4489 |
1 |
wr.write(domResult.getDocument().getRootElement()); |
| 4490 |
|
} |
| 4491 |
|
|
| 4492 |
|
|
| 4493 |
|
|
| 4494 |
|
|
| 4495 |
|
@param |
| 4496 |
|
@param |
| 4497 |
|
@param |
| 4498 |
|
@param |
| 4499 |
|
@param |
| 4500 |
|
@throws |
| 4501 |
|
@throws |
| 4502 |
|
@since |
| 4503 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4504 |
25 |
public void toXML(OutputStream out, boolean bWithObjects, boolean bWithRendering, boolean bWithAttachmentContent,... |
| 4505 |
|
boolean bWithVersions, XWikiContext context) throws XWikiException, IOException |
| 4506 |
|
{ |
| 4507 |
25 |
toXML(new DefaultOutputStreamOutputTarget(out), bWithObjects, bWithRendering, bWithAttachmentContent, |
| 4508 |
|
bWithVersions, context); |
| 4509 |
|
} |
| 4510 |
|
|
| 4511 |
|
|
| 4512 |
|
|
| 4513 |
|
|
| 4514 |
|
@param |
| 4515 |
|
@param |
| 4516 |
|
@param |
| 4517 |
|
@param |
| 4518 |
|
@param |
| 4519 |
|
@param |
| 4520 |
|
@throws |
| 4521 |
|
@since |
| 4522 |
|
|
| |
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
|
| 4523 |
6332 |
public void toXML(OutputTarget out, boolean bWithObjects, boolean bWithRendering, boolean bWithAttachmentContent,... |
| 4524 |
|
boolean bWithVersions, XWikiContext context) throws XWikiException |
| 4525 |
|
{ |
| 4526 |
|
|
| 4527 |
6332 |
DocumentInstanceInputProperties documentProperties = new DocumentInstanceInputProperties(); |
| 4528 |
6332 |
documentProperties.setWithWikiObjects(bWithObjects); |
| 4529 |
6332 |
documentProperties.setWithWikiDocumentContentHTML(bWithRendering); |
| 4530 |
6332 |
documentProperties.setWithWikiAttachments(bWithAttachmentContent); |
| 4531 |
6332 |
documentProperties.setWithJRCSRevisions(bWithVersions); |
| 4532 |
6332 |
documentProperties.setWithRevisions(false); |
| 4533 |
|
|
| 4534 |
|
|
| 4535 |
6332 |
XAROutputProperties xarProperties = new XAROutputProperties(); |
| 4536 |
6332 |
xarProperties.setPreserveVersion(bWithVersions); |
| 4537 |
6332 |
xarProperties.setEncoding(context.getWiki().getEncoding()); |
| 4538 |
|
|
| 4539 |
6332 |
try { |
| 4540 |
6332 |
Utils.getComponent(XWikiDocumentFilterUtils.class).exportEntity(this, out, xarProperties, |
| 4541 |
|
documentProperties); |
| 4542 |
|
} catch (Exception e) { |
| 4543 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_DOC, XWikiException.ERROR_DOC_XML_PARSING, |
| 4544 |
|
"Error parsing xml", e, null); |
| 4545 |
|
} |
| 4546 |
|
} |
| 4547 |
|
|
| |
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 12 |
Complexity Density: 0.32 |
|
| 4548 |
0 |
protected String encodedXMLStringAsUTF8(String xmlString)... |
| 4549 |
|
{ |
| 4550 |
0 |
if (xmlString == null) { |
| 4551 |
0 |
return ""; |
| 4552 |
|
} |
| 4553 |
|
|
| 4554 |
0 |
int length = xmlString.length(); |
| 4555 |
0 |
char character; |
| 4556 |
0 |
StringBuilder result = new StringBuilder(); |
| 4557 |
0 |
for (int i = 0; i < length; i++) { |
| 4558 |
0 |
character = xmlString.charAt(i); |
| 4559 |
0 |
switch (character) { |
| 4560 |
0 |
case '&': |
| 4561 |
0 |
result.append("&"); |
| 4562 |
0 |
break; |
| 4563 |
0 |
case '"': |
| 4564 |
0 |
result.append("""); |
| 4565 |
0 |
break; |
| 4566 |
0 |
case '<': |
| 4567 |
0 |
result.append("<"); |
| 4568 |
0 |
break; |
| 4569 |
0 |
case '>': |
| 4570 |
0 |
result.append(">"); |
| 4571 |
0 |
break; |
| 4572 |
0 |
case '\n': |
| 4573 |
0 |
result.append("\n"); |
| 4574 |
0 |
break; |
| 4575 |
0 |
case '\r': |
| 4576 |
0 |
result.append("\r"); |
| 4577 |
0 |
break; |
| 4578 |
0 |
case '\t': |
| 4579 |
0 |
result.append("\t"); |
| 4580 |
0 |
break; |
| 4581 |
0 |
default: |
| 4582 |
0 |
if (character < 0x20) { |
| 4583 |
0 |
} else if (character > 0x7F) { |
| 4584 |
0 |
result.append("&#x"); |
| 4585 |
0 |
result.append(Integer.toHexString(character).toUpperCase()); |
| 4586 |
0 |
result.append(";"); |
| 4587 |
|
} else { |
| 4588 |
0 |
result.append(character); |
| 4589 |
|
} |
| 4590 |
0 |
break; |
| 4591 |
|
} |
| 4592 |
|
} |
| 4593 |
|
|
| 4594 |
0 |
return result.toString(); |
| 4595 |
|
} |
| 4596 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 4597 |
0 |
protected String getElement(Element docel, String name)... |
| 4598 |
|
{ |
| 4599 |
0 |
Element el = docel.element(name); |
| 4600 |
0 |
if (el == null) { |
| 4601 |
0 |
return ""; |
| 4602 |
|
} else { |
| 4603 |
0 |
return el.getText(); |
| 4604 |
|
} |
| 4605 |
|
} |
| 4606 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4607 |
35 |
public void fromXML(String xml) throws XWikiException... |
| 4608 |
|
{ |
| 4609 |
35 |
fromXML(xml, false); |
| 4610 |
|
} |
| 4611 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4612 |
0 |
public void fromXML(InputStream is) throws XWikiException... |
| 4613 |
|
{ |
| 4614 |
0 |
fromXML(is, false); |
| 4615 |
|
} |
| 4616 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 4617 |
2027 |
public void fromXML(InputSource source, boolean withArchive) throws XWikiException... |
| 4618 |
|
{ |
| 4619 |
|
|
| 4620 |
2027 |
DocumentInstanceOutputProperties documentProperties = new DocumentInstanceOutputProperties(); |
| 4621 |
2027 |
documentProperties.setVersionPreserved(withArchive); |
| 4622 |
|
|
| 4623 |
|
|
| 4624 |
2027 |
XARInputProperties xarProperties = new XARInputProperties(); |
| 4625 |
2027 |
xarProperties.setWithHistory(withArchive); |
| 4626 |
|
|
| 4627 |
2027 |
try { |
| 4628 |
2027 |
Utils.getComponent(XWikiDocumentFilterUtils.class).importEntity(XWikiDocument.class, this, source, |
| 4629 |
|
xarProperties, documentProperties); |
| 4630 |
|
} catch (Exception e) { |
| 4631 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_DOC, XWikiException.ERROR_DOC_XML_PARSING, |
| 4632 |
|
"Error parsing xml", e, null); |
| 4633 |
|
} |
| 4634 |
|
} |
| 4635 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4636 |
39 |
public void fromXML(String source, boolean withArchive) throws XWikiException... |
| 4637 |
|
{ |
| 4638 |
39 |
fromXML(new StringInputSource(source), withArchive); |
| 4639 |
|
} |
| 4640 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4641 |
1988 |
public void fromXML(InputStream source, boolean withArchive) throws XWikiException... |
| 4642 |
|
{ |
| 4643 |
1988 |
fromXML(new DefaultInputStreamInputSource(source), withArchive); |
| 4644 |
|
} |
| 4645 |
|
|
| 4646 |
|
|
| 4647 |
|
@deprecated@link |
| 4648 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 4649 |
1 |
@Deprecated... |
| 4650 |
|
public void fromXML(Document domdoc, boolean withArchive) throws XWikiException |
| 4651 |
|
{ |
| 4652 |
|
|
| 4653 |
1 |
StringWriter writer = new StringWriter(); |
| 4654 |
1 |
try { |
| 4655 |
1 |
org.dom4j.io.XMLWriter domWriter = new org.dom4j.io.XMLWriter(writer); |
| 4656 |
1 |
domWriter.write(domdoc); |
| 4657 |
1 |
domWriter.flush(); |
| 4658 |
|
} catch (IOException e) { |
| 4659 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_DOC, XWikiException.ERROR_DOC_XML_PARSING, |
| 4660 |
|
"Error parsing xml", e, null); |
| 4661 |
|
} |
| 4662 |
|
|
| 4663 |
|
|
| 4664 |
1 |
fromXML(writer.toString(), withArchive); |
| 4665 |
|
} |
| 4666 |
|
|
| 4667 |
|
|
| 4668 |
|
|
| 4669 |
|
|
| 4670 |
|
@param |
| 4671 |
|
@return |
| 4672 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4673 |
0 |
public static boolean containsXMLWikiDocument(Document domdoc)... |
| 4674 |
|
{ |
| 4675 |
0 |
return domdoc.getRootElement().getName().equals(XarDocumentModel.ELEMENT_DOCUMENT); |
| 4676 |
|
} |
| 4677 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 4678 |
158 |
public void setAttachmentList(List<XWikiAttachment> list)... |
| 4679 |
|
{ |
| 4680 |
|
|
| 4681 |
|
|
| 4682 |
158 |
if (this.attachmentList != list) { |
| 4683 |
156 |
this.attachmentList.clear(); |
| 4684 |
156 |
this.attachmentList.addAll(list); |
| 4685 |
|
} |
| 4686 |
|
} |
| 4687 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4688 |
138688 |
public List<XWikiAttachment> getAttachmentList()... |
| 4689 |
|
{ |
| 4690 |
138689 |
return this.attachmentList; |
| 4691 |
|
} |
| 4692 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4693 |
0 |
public void saveAllAttachments(XWikiContext context) throws XWikiException... |
| 4694 |
|
{ |
| 4695 |
0 |
saveAllAttachments(true, true, context); |
| 4696 |
|
} |
| 4697 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 4698 |
0 |
public void saveAllAttachments(boolean updateParent, boolean transaction, XWikiContext context)... |
| 4699 |
|
throws XWikiException |
| 4700 |
|
{ |
| 4701 |
0 |
for (XWikiAttachment attachment : this.attachmentList) { |
| 4702 |
0 |
saveAttachmentContent(attachment, false, transaction, context); |
| 4703 |
|
} |
| 4704 |
|
|
| 4705 |
|
|
| 4706 |
0 |
if (updateParent) { |
| 4707 |
0 |
context.getWiki().saveDocument(this, context); |
| 4708 |
|
} |
| 4709 |
|
} |
| 4710 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 4711 |
0 |
public void saveAttachmentsContent(List<XWikiAttachment> attachments, XWikiContext context) throws XWikiException... |
| 4712 |
|
{ |
| 4713 |
0 |
String database = context.getWikiId(); |
| 4714 |
0 |
try { |
| 4715 |
|
|
| 4716 |
0 |
if (getDatabase() != null) { |
| 4717 |
0 |
context.setWikiId(getDatabase()); |
| 4718 |
|
} |
| 4719 |
|
|
| 4720 |
0 |
context.getWiki().getAttachmentStore().saveAttachmentsContent(attachments, this, true, context, true); |
| 4721 |
|
} catch (OutOfMemoryError e) { |
| 4722 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_JAVA_HEAP_SPACE, |
| 4723 |
|
"Out Of Memory Exception"); |
| 4724 |
|
} finally { |
| 4725 |
0 |
if (database != null) { |
| 4726 |
0 |
context.setWikiId(database); |
| 4727 |
|
} |
| 4728 |
|
} |
| 4729 |
|
} |
| 4730 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4731 |
0 |
public void saveAttachmentContent(XWikiAttachment attachment, XWikiContext context) throws XWikiException... |
| 4732 |
|
{ |
| 4733 |
0 |
saveAttachmentContent(attachment, true, true, context); |
| 4734 |
|
} |
| 4735 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
| 4736 |
0 |
public void saveAttachmentContent(XWikiAttachment attachment, boolean updateParent, boolean transaction,... |
| 4737 |
|
XWikiContext context) throws XWikiException |
| 4738 |
|
{ |
| 4739 |
0 |
String currentWiki = context.getWikiId(); |
| 4740 |
0 |
try { |
| 4741 |
|
|
| 4742 |
|
|
| 4743 |
0 |
if (getDatabase() != null) { |
| 4744 |
0 |
context.setWikiId(getDatabase()); |
| 4745 |
|
} |
| 4746 |
|
|
| 4747 |
|
|
| 4748 |
0 |
context.getWiki().getAttachmentStore().saveAttachmentContent(attachment, false, context, transaction); |
| 4749 |
|
|
| 4750 |
|
|
| 4751 |
0 |
setMetaDataDirty(true); |
| 4752 |
|
|
| 4753 |
|
|
| 4754 |
0 |
if (updateParent) { |
| 4755 |
0 |
context.getWiki().saveDocument(this, context); |
| 4756 |
|
} |
| 4757 |
|
} catch (OutOfMemoryError e) { |
| 4758 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_JAVA_HEAP_SPACE, |
| 4759 |
|
"Out Of Memory Exception"); |
| 4760 |
|
} finally { |
| 4761 |
0 |
if (currentWiki != null) { |
| 4762 |
0 |
context.setWikiId(currentWiki); |
| 4763 |
|
} |
| 4764 |
|
} |
| 4765 |
|
} |
| 4766 |
|
|
| |
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 4767 |
280 |
public void loadAttachmentContent(XWikiAttachment attachment, XWikiContext context) throws XWikiException... |
| 4768 |
|
{ |
| 4769 |
280 |
String database = context.getWikiId(); |
| 4770 |
280 |
try { |
| 4771 |
|
|
| 4772 |
|
|
| 4773 |
278 |
if (getDatabase() != null) { |
| 4774 |
277 |
context.setWikiId(getDatabase()); |
| 4775 |
|
} |
| 4776 |
|
|
| 4777 |
279 |
context.getWiki().getAttachmentStore().loadAttachmentContent(attachment, context, true); |
| 4778 |
|
} finally { |
| 4779 |
280 |
if (database != null) { |
| 4780 |
280 |
context.setWikiId(database); |
| 4781 |
|
} |
| 4782 |
|
} |
| 4783 |
|
} |
| 4784 |
|
|
| 4785 |
|
|
| 4786 |
|
|
| 4787 |
|
|
| 4788 |
|
|
| 4789 |
|
|
| 4790 |
|
|
| 4791 |
|
@param |
| 4792 |
|
@return |
| 4793 |
|
@since |
| 4794 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4795 |
8 |
public XWikiAttachment removeAttachment(XWikiAttachment attachment)... |
| 4796 |
|
{ |
| 4797 |
8 |
return removeAttachment(attachment, true); |
| 4798 |
|
} |
| 4799 |
|
|
| 4800 |
|
|
| 4801 |
|
|
| 4802 |
|
|
| 4803 |
|
|
| 4804 |
|
@param |
| 4805 |
|
@param |
| 4806 |
|
@return |
| 4807 |
|
@since |
| 4808 |
|
|
| |
|
| 76.9% |
Uncovered Elements: 3 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 4809 |
8 |
public XWikiAttachment removeAttachment(XWikiAttachment attachmentToRemove, boolean toRecycleBin)... |
| 4810 |
|
{ |
| 4811 |
8 |
List<XWikiAttachment> list = getAttachmentList(); |
| 4812 |
8 |
for (int i = 0; i < list.size(); i++) { |
| 4813 |
8 |
XWikiAttachment attachment = list.get(i); |
| 4814 |
8 |
if (attachmentToRemove.getFilename().equals(attachment.getFilename())) { |
| 4815 |
8 |
list.remove(i); |
| 4816 |
8 |
this.attachmentsToRemove.add(new XWikiAttachmentToRemove(attachment, toRecycleBin)); |
| 4817 |
8 |
setMetaDataDirty(true); |
| 4818 |
8 |
return attachment; |
| 4819 |
|
} |
| 4820 |
|
} |
| 4821 |
|
|
| 4822 |
0 |
return null; |
| 4823 |
|
} |
| 4824 |
|
|
| 4825 |
|
|
| 4826 |
|
@return |
| 4827 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4828 |
7707 |
public List<XWikiAttachmentToRemove> getAttachmentsToRemove()... |
| 4829 |
|
{ |
| 4830 |
7707 |
return this.attachmentsToRemove; |
| 4831 |
|
} |
| 4832 |
|
|
| 4833 |
|
|
| 4834 |
|
|
| 4835 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4836 |
5 |
public void clearAttachmentsToRemove()... |
| 4837 |
|
{ |
| 4838 |
5 |
this.attachmentsToRemove.clear(); |
| 4839 |
|
} |
| 4840 |
|
|
| 4841 |
|
|
| 4842 |
|
|
| 4843 |
|
|
| 4844 |
|
|
| 4845 |
|
|
| 4846 |
|
|
| 4847 |
|
@param |
| 4848 |
|
@return |
| 4849 |
|
@throws |
| 4850 |
|
@since |
| 4851 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4852 |
5 |
public List<DocumentReference> getBackLinkedReferences(XWikiContext context) throws XWikiException... |
| 4853 |
|
{ |
| 4854 |
5 |
return getStore(context).loadBacklinks(getDocumentReference(), true, context); |
| 4855 |
|
} |
| 4856 |
|
|
| 4857 |
|
|
| 4858 |
|
@deprecated@link |
| 4859 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 4860 |
14 |
@Deprecated... |
| 4861 |
|
public List<String> getBackLinkedPages(XWikiContext context) throws XWikiException |
| 4862 |
|
{ |
| 4863 |
14 |
return getStore(context).loadBacklinks(getFullName(), context, true); |
| 4864 |
|
} |
| 4865 |
|
|
| 4866 |
|
|
| 4867 |
|
|
| 4868 |
|
|
| 4869 |
|
|
| 4870 |
|
|
| 4871 |
|
|
| 4872 |
|
@link |
| 4873 |
|
|
| 4874 |
|
|
| 4875 |
|
@param |
| 4876 |
|
@return |
| 4877 |
|
@throws |
| 4878 |
|
@since |
| 4879 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
| 4880 |
3805 |
public Set<XWikiLink> getUniqueWikiLinkedPages(XWikiContext context) throws XWikiException... |
| 4881 |
|
{ |
| 4882 |
3805 |
Set<XWikiLink> links; |
| 4883 |
|
|
| 4884 |
3805 |
if (is10Syntax()) { |
| 4885 |
3 |
links = new LinkedHashSet<>(getStore(context).loadLinks(getId(), context, true)); |
| 4886 |
|
} else { |
| 4887 |
3802 |
Set<String> linkedPages = getUniqueLinkedPages(context); |
| 4888 |
3802 |
links = new LinkedHashSet<>(linkedPages.size()); |
| 4889 |
3802 |
for (String linkedPage : linkedPages) { |
| 4890 |
40 |
XWikiLink wikiLink = new XWikiLink(); |
| 4891 |
|
|
| 4892 |
40 |
wikiLink.setDocId(getId()); |
| 4893 |
40 |
wikiLink.setFullName(LOCAL_REFERENCE_SERIALIZER.serialize(getDocumentReference())); |
| 4894 |
40 |
wikiLink.setLink(linkedPage); |
| 4895 |
|
|
| 4896 |
40 |
links.add(wikiLink); |
| 4897 |
|
} |
| 4898 |
|
} |
| 4899 |
|
|
| 4900 |
3805 |
return links; |
| 4901 |
|
} |
| 4902 |
|
|
| 4903 |
|
|
| 4904 |
|
|
| 4905 |
|
|
| 4906 |
|
|
| 4907 |
|
@param |
| 4908 |
|
@return |
| 4909 |
|
@since |
| 4910 |
|
|
| |
|
| 79.6% |
Uncovered Elements: 11 (54) |
Complexity: 19 |
Complexity Density: 0.56 |
|
| 4911 |
1 |
private Set<String> getUniqueLinkedPages10(XWikiContext context)... |
| 4912 |
|
{ |
| 4913 |
1 |
Set<String> pageNames; |
| 4914 |
|
|
| 4915 |
1 |
try { |
| 4916 |
1 |
List<String> list = context.getUtil().getUniqueMatches(getContent(), "\\[(.*?)\\]", 1); |
| 4917 |
1 |
pageNames = new HashSet<String>(list.size()); |
| 4918 |
|
|
| 4919 |
1 |
DocumentReference currentDocumentReference = getDocumentReference(); |
| 4920 |
1 |
for (String name : list) { |
| 4921 |
7 |
int i1 = name.indexOf('>'); |
| 4922 |
7 |
if (i1 != -1) { |
| 4923 |
3 |
name = name.substring(i1 + 1); |
| 4924 |
|
} |
| 4925 |
7 |
i1 = name.indexOf(">"); |
| 4926 |
7 |
if (i1 != -1) { |
| 4927 |
0 |
name = name.substring(i1 + 4); |
| 4928 |
|
} |
| 4929 |
7 |
i1 = name.indexOf('#'); |
| 4930 |
7 |
if (i1 != -1) { |
| 4931 |
1 |
name = name.substring(0, i1); |
| 4932 |
|
} |
| 4933 |
7 |
i1 = name.indexOf('?'); |
| 4934 |
7 |
if (i1 != -1) { |
| 4935 |
1 |
name = name.substring(0, i1); |
| 4936 |
|
} |
| 4937 |
|
|
| 4938 |
|
|
| 4939 |
7 |
if (name.trim().equals("") || (name.indexOf('$') != -1) || (name.indexOf("://") != -1) |
| 4940 |
|
|| (name.indexOf('"') != -1) || (name.indexOf('\'') != -1) || (name.indexOf("..") != -1) |
| 4941 |
|
|| (name.indexOf(':') != -1) || (name.indexOf('=') != -1)) { |
| 4942 |
3 |
continue; |
| 4943 |
|
} |
| 4944 |
|
|
| 4945 |
|
|
| 4946 |
4 |
String newname = StringUtils.replace(Util.noaccents(name), " ", ""); |
| 4947 |
|
|
| 4948 |
|
|
| 4949 |
4 |
if (newname.indexOf('.') == -1) { |
| 4950 |
2 |
newname = getSpace() + "." + name; |
| 4951 |
|
} |
| 4952 |
4 |
if (context.getWiki().exists(newname, context)) { |
| 4953 |
4 |
name = newname; |
| 4954 |
|
} else { |
| 4955 |
|
|
| 4956 |
0 |
if (name.indexOf('.') == -1) { |
| 4957 |
0 |
name = getSpace() + "." + name; |
| 4958 |
|
} |
| 4959 |
|
} |
| 4960 |
|
|
| 4961 |
|
|
| 4962 |
4 |
if (!StringUtils.isEmpty(name)) { |
| 4963 |
|
|
| 4964 |
|
|
| 4965 |
|
|
| 4966 |
4 |
DocumentReference documentReference = getCurrentDocumentReferenceResolver().resolve(name); |
| 4967 |
|
|
| 4968 |
|
|
| 4969 |
4 |
if (!documentReference.equals(currentDocumentReference)) { |
| 4970 |
4 |
pageNames.add(getCompactEntityReferenceSerializer().serialize(documentReference)); |
| 4971 |
|
} |
| 4972 |
|
} |
| 4973 |
|
} |
| 4974 |
|
|
| 4975 |
1 |
return pageNames; |
| 4976 |
|
} catch (Exception e) { |
| 4977 |
|
|
| 4978 |
0 |
LOGGER.error("Failed to get linked documents", e); |
| 4979 |
|
|
| 4980 |
0 |
return null; |
| 4981 |
|
} |
| 4982 |
|
} |
| 4983 |
|
|
| 4984 |
|
|
| 4985 |
|
|
| 4986 |
|
|
| 4987 |
|
|
| 4988 |
|
@param |
| 4989 |
|
@return |
| 4990 |
|
@since |
| 4991 |
|
|
| |
|
| 97.1% |
Uncovered Elements: 1 (34) |
Complexity: 6 |
Complexity Density: 0.23 |
|
| 4992 |
3804 |
public Set<String> getUniqueLinkedPages(XWikiContext context)... |
| 4993 |
|
{ |
| 4994 |
3804 |
Set<String> pageNames; |
| 4995 |
|
|
| 4996 |
3804 |
XWikiDocument contextDoc = context.getDoc(); |
| 4997 |
3804 |
String contextWiki = context.getWikiId(); |
| 4998 |
|
|
| 4999 |
3804 |
try { |
| 5000 |
|
|
| 5001 |
3804 |
context.setDoc(this); |
| 5002 |
|
|
| 5003 |
3804 |
context.setWikiId(getDatabase()); |
| 5004 |
|
|
| 5005 |
3804 |
if (is10Syntax()) { |
| 5006 |
1 |
pageNames = getUniqueLinkedPages10(context); |
| 5007 |
|
} else { |
| 5008 |
3803 |
XDOM dom = getXDOM(); |
| 5009 |
|
|
| 5010 |
|
|
| 5011 |
3803 |
List<LinkBlock> linkBlocks = |
| 5012 |
|
dom.getBlocks(new ClassBlockMatcher(LinkBlock.class), Block.Axes.DESCENDANT); |
| 5013 |
3803 |
pageNames = new LinkedHashSet<String>(linkBlocks.size()); |
| 5014 |
|
|
| 5015 |
3803 |
DocumentReference currentDocumentReference = getDocumentReference(); |
| 5016 |
|
|
| 5017 |
3803 |
for (LinkBlock linkBlock : linkBlocks) { |
| 5018 |
66 |
ResourceReference reference = linkBlock.getReference(); |
| 5019 |
66 |
String referenceString = reference.getReference(); |
| 5020 |
66 |
ResourceType resourceType = reference.getType(); |
| 5021 |
|
|
| 5022 |
|
|
| 5023 |
66 |
if (!ResourceType.DOCUMENT.equals(resourceType) && !ResourceType.SPACE.equals(resourceType)) { |
| 5024 |
|
|
| 5025 |
18 |
continue; |
| 5026 |
|
} |
| 5027 |
|
|
| 5028 |
|
|
| 5029 |
48 |
if (StringUtils.isEmpty(referenceString)) { |
| 5030 |
3 |
continue; |
| 5031 |
|
} |
| 5032 |
|
|
| 5033 |
|
|
| 5034 |
|
|
| 5035 |
45 |
EntityReference documentReference = |
| 5036 |
|
getResourceReferenceEntityReferenceResolver().resolve(reference, EntityType.DOCUMENT); |
| 5037 |
|
|
| 5038 |
|
|
| 5039 |
45 |
if (!documentReference.equals(currentDocumentReference)) { |
| 5040 |
|
|
| 5041 |
|
|
| 5042 |
|
|
| 5043 |
|
|
| 5044 |
|
|
| 5045 |
45 |
pageNames.add(getCompactWikiEntityReferenceSerializer().serialize(documentReference)); |
| 5046 |
|
} |
| 5047 |
|
} |
| 5048 |
|
} |
| 5049 |
|
} finally { |
| 5050 |
3804 |
context.setDoc(contextDoc); |
| 5051 |
3804 |
context.setWikiId(contextWiki); |
| 5052 |
|
} |
| 5053 |
|
|
| 5054 |
3804 |
return pageNames; |
| 5055 |
|
} |
| 5056 |
|
|
| 5057 |
|
|
| 5058 |
|
|
| 5059 |
|
@link |
| 5060 |
|
|
| 5061 |
|
@since |
| 5062 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5063 |
5 |
public List<DocumentReference> getChildrenReferences(XWikiContext context) throws XWikiException... |
| 5064 |
|
{ |
| 5065 |
5 |
return getChildrenReferences(0, 0, context); |
| 5066 |
|
} |
| 5067 |
|
|
| 5068 |
|
|
| 5069 |
|
@deprecated@link |
| 5070 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5071 |
554 |
@Deprecated... |
| 5072 |
|
public List<String> getChildren(XWikiContext context) throws XWikiException |
| 5073 |
|
{ |
| 5074 |
554 |
return getChildren(0, 0, context); |
| 5075 |
|
} |
| 5076 |
|
|
| 5077 |
|
|
| 5078 |
|
|
| 5079 |
|
|
| 5080 |
|
@param |
| 5081 |
|
@param |
| 5082 |
|
@param@link |
| 5083 |
|
@return |
| 5084 |
|
@throws |
| 5085 |
|
@since |
| 5086 |
|
|
| |
|
| 93.3% |
Uncovered Elements: 1 (15) |
Complexity: 2 |
Complexity Density: 0.13 |
|
| 5087 |
560 |
public List<DocumentReference> getChildrenReferences(int nb, int start, XWikiContext context) throws XWikiException... |
| 5088 |
|
{ |
| 5089 |
|
|
| 5090 |
|
|
| 5091 |
|
|
| 5092 |
|
|
| 5093 |
|
|
| 5094 |
|
|
| 5095 |
|
|
| 5096 |
|
|
| 5097 |
|
|
| 5098 |
|
|
| 5099 |
560 |
List<DocumentReference> children = new ArrayList<DocumentReference>(); |
| 5100 |
|
|
| 5101 |
560 |
try { |
| 5102 |
560 |
Query query = getStore().getQueryManager().createQuery( |
| 5103 |
|
"select distinct doc.fullName from XWikiDocument doc where " |
| 5104 |
|
+ "doc.parent=:prefixedFullName or doc.parent=:fullName or (doc.parent=:name and doc.space=:space)", |
| 5105 |
|
Query.XWQL); |
| 5106 |
560 |
query.addFilter(Utils.getComponent(QueryFilter.class, "hidden")); |
| 5107 |
560 |
query.bindValue("prefixedFullName", |
| 5108 |
|
getDefaultEntityReferenceSerializer().serialize(getDocumentReference())); |
| 5109 |
560 |
query.bindValue("fullName", LOCAL_REFERENCE_SERIALIZER.serialize(getDocumentReference())); |
| 5110 |
560 |
query.bindValue("name", getDocumentReference().getName()); |
| 5111 |
560 |
query.bindValue("space", |
| 5112 |
|
LOCAL_REFERENCE_SERIALIZER.serialize(getDocumentReference().getLastSpaceReference())); |
| 5113 |
560 |
query.setLimit(nb).setOffset(start); |
| 5114 |
|
|
| 5115 |
560 |
List<String> queryResults = query.execute(); |
| 5116 |
560 |
WikiReference wikiReference = this.getDocumentReference().getWikiReference(); |
| 5117 |
560 |
for (String fullName : queryResults) { |
| 5118 |
28 |
children.add(getCurrentDocumentReferenceResolver().resolve(fullName, wikiReference)); |
| 5119 |
|
} |
| 5120 |
|
} catch (QueryException e) { |
| 5121 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, |
| 5122 |
|
String.format("Failed to retrieve children for document [%s]", this.getDocumentReference()), e); |
| 5123 |
|
} |
| 5124 |
|
|
| 5125 |
560 |
return children; |
| 5126 |
|
} |
| 5127 |
|
|
| 5128 |
|
|
| 5129 |
|
@deprecated@link |
| 5130 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 5131 |
554 |
@Deprecated... |
| 5132 |
|
public List<String> getChildren(int nb, int start, XWikiContext context) throws XWikiException |
| 5133 |
|
{ |
| 5134 |
554 |
List<String> childrenNames = new ArrayList<String>(); |
| 5135 |
554 |
for (DocumentReference reference : getChildrenReferences(nb, start, context)) { |
| 5136 |
26 |
childrenNames.add(LOCAL_REFERENCE_SERIALIZER.serialize(reference)); |
| 5137 |
|
} |
| 5138 |
554 |
return childrenNames; |
| 5139 |
|
} |
| 5140 |
|
|
| 5141 |
|
|
| 5142 |
|
@since |
| 5143 |
|
|
| |
|
| 14.8% |
Uncovered Elements: 23 (27) |
Complexity: 5 |
Complexity Density: 0.26 |
|
| 5144 |
2 |
public void renameProperties(DocumentReference classReference, Map<String, String> fieldsToRename)... |
| 5145 |
|
{ |
| 5146 |
2 |
List<BaseObject> objects = this.xObjects.get(classReference); |
| 5147 |
2 |
if (objects == null) { |
| 5148 |
2 |
return; |
| 5149 |
|
} |
| 5150 |
|
|
| 5151 |
0 |
boolean isDirty = false; |
| 5152 |
0 |
for (BaseObject bobject : objects) { |
| 5153 |
0 |
if (bobject == null) { |
| 5154 |
0 |
continue; |
| 5155 |
|
} |
| 5156 |
0 |
for (Map.Entry<String, String> entry : fieldsToRename.entrySet()) { |
| 5157 |
0 |
String origname = entry.getKey(); |
| 5158 |
0 |
String newname = entry.getValue(); |
| 5159 |
0 |
BaseProperty origprop = (BaseProperty) bobject.safeget(origname); |
| 5160 |
0 |
if (origprop != null) { |
| 5161 |
0 |
BaseProperty prop = origprop.clone(); |
| 5162 |
0 |
bobject.removeField(origname); |
| 5163 |
0 |
prop.setName(newname); |
| 5164 |
0 |
bobject.addField(newname, prop); |
| 5165 |
|
|
| 5166 |
0 |
isDirty = true; |
| 5167 |
|
} |
| 5168 |
|
} |
| 5169 |
|
} |
| 5170 |
|
|
| 5171 |
|
|
| 5172 |
0 |
if (isDirty) { |
| 5173 |
0 |
setMetaDataDirty(true); |
| 5174 |
|
} |
| 5175 |
|
} |
| 5176 |
|
|
| 5177 |
|
|
| 5178 |
|
@deprecated@link |
| 5179 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5180 |
2 |
@Deprecated... |
| 5181 |
|
public void renameProperties(String className, Map<String, String> fieldsToRename) |
| 5182 |
|
{ |
| 5183 |
2 |
renameProperties(resolveClassReference(className), fieldsToRename); |
| 5184 |
|
} |
| 5185 |
|
|
| 5186 |
|
|
| 5187 |
|
@since |
| 5188 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 5189 |
115 |
public void addXObjectToRemove(BaseObject object)... |
| 5190 |
|
{ |
| 5191 |
115 |
getXObjectsToRemove().add(object); |
| 5192 |
115 |
object.setOwnerDocument(null); |
| 5193 |
115 |
setMetaDataDirty(true); |
| 5194 |
|
} |
| 5195 |
|
|
| 5196 |
|
|
| 5197 |
|
|
| 5198 |
|
|
| 5199 |
|
|
| 5200 |
|
@param |
| 5201 |
|
@since |
| 5202 |
|
|
| |
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 5203 |
5 |
public void addXObjectsToRemoveFromVersion(XWikiDocument previousVersion)... |
| 5204 |
|
{ |
| 5205 |
5 |
if (previousVersion == null) { |
| 5206 |
0 |
return; |
| 5207 |
|
} |
| 5208 |
5 |
for (List<BaseObject> objects : previousVersion.getXObjects().values()) { |
| 5209 |
4 |
for (BaseObject originalObj : objects) { |
| 5210 |
8 |
if (originalObj != null) { |
| 5211 |
8 |
BaseObject newObj = getXObject(originalObj.getXClassReference(), originalObj.getNumber()); |
| 5212 |
8 |
if (newObj == null) { |
| 5213 |
|
|
| 5214 |
2 |
this.addXObjectToRemove(originalObj); |
| 5215 |
|
} |
| 5216 |
|
} |
| 5217 |
|
} |
| 5218 |
|
} |
| 5219 |
|
} |
| 5220 |
|
|
| 5221 |
|
|
| 5222 |
|
@deprecated@link |
| 5223 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5224 |
0 |
@Deprecated... |
| 5225 |
|
public void addObjectsToRemove(BaseObject object) |
| 5226 |
|
{ |
| 5227 |
0 |
addXObjectToRemove(object); |
| 5228 |
|
} |
| 5229 |
|
|
| 5230 |
|
|
| 5231 |
|
@since |
| 5232 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5233 |
4124 |
public List<BaseObject> getXObjectsToRemove()... |
| 5234 |
|
{ |
| 5235 |
4124 |
return this.xObjectsToRemove; |
| 5236 |
|
} |
| 5237 |
|
|
| 5238 |
|
|
| 5239 |
|
@deprecated@link |
| 5240 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5241 |
0 |
@Deprecated... |
| 5242 |
|
public ArrayList<BaseObject> getObjectsToRemove() |
| 5243 |
|
{ |
| 5244 |
0 |
return (ArrayList<BaseObject>) getXObjectsToRemove(); |
| 5245 |
|
} |
| 5246 |
|
|
| 5247 |
|
|
| 5248 |
|
@since |
| 5249 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5250 |
51 |
public void setXObjectsToRemove(List<BaseObject> objectsToRemove)... |
| 5251 |
|
{ |
| 5252 |
51 |
this.xObjectsToRemove = objectsToRemove; |
| 5253 |
51 |
setMetaDataDirty(true); |
| 5254 |
|
} |
| 5255 |
|
|
| |
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 5256 |
3813 |
public List<String> getIncludedPages(XWikiContext context)... |
| 5257 |
|
{ |
| 5258 |
3813 |
try { |
| 5259 |
3813 |
return getIncludedPagesInternal(context); |
| 5260 |
|
} catch (Exception e) { |
| 5261 |
|
|
| 5262 |
|
|
| 5263 |
0 |
LOGGER.error("Failed to get included pages for [{}]", getDocumentReference(), e); |
| 5264 |
0 |
return Collections.emptyList(); |
| 5265 |
|
} |
| 5266 |
|
} |
| 5267 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (32) |
Complexity: 9 |
Complexity Density: 0.45 |
|
| 5268 |
3813 |
private List<String> getIncludedPagesInternal(XWikiContext context)... |
| 5269 |
|
{ |
| 5270 |
3813 |
if (is10Syntax()) { |
| 5271 |
3 |
return getIncludedPagesForXWiki10Syntax(getContent(), context); |
| 5272 |
|
} else { |
| 5273 |
|
|
| 5274 |
3810 |
XDOM dom = getXDOM(); |
| 5275 |
|
|
| 5276 |
3810 |
List<String> result = new ArrayList<String>(); |
| 5277 |
3810 |
List<MacroBlock> macroBlocks = |
| 5278 |
|
dom.getBlocks(new ClassBlockMatcher(MacroBlock.class), Block.Axes.DESCENDANT); |
| 5279 |
3810 |
for (MacroBlock macroBlock : macroBlocks) { |
| 5280 |
|
|
| 5281 |
|
|
| 5282 |
|
|
| 5283 |
|
|
| 5284 |
|
|
| 5285 |
|
|
| 5286 |
1883 |
if (macroBlock.getId().equalsIgnoreCase("include") || macroBlock.getId().equalsIgnoreCase("display")) { |
| 5287 |
455 |
String documentName = macroBlock.getParameters().get("reference"); |
| 5288 |
455 |
if (StringUtils.isEmpty(documentName)) { |
| 5289 |
5 |
documentName = macroBlock.getParameters().get("document"); |
| 5290 |
5 |
if (StringUtils.isEmpty(documentName)) { |
| 5291 |
4 |
continue; |
| 5292 |
|
} |
| 5293 |
|
} |
| 5294 |
|
|
| 5295 |
451 |
DocumentReference documentReference = |
| 5296 |
|
getExplicitDocumentReferenceResolver().resolve(documentName, getDocumentReference()); |
| 5297 |
451 |
if (this.getDocumentReference().equals(documentReference)) { |
| 5298 |
|
|
| 5299 |
2 |
continue; |
| 5300 |
|
} |
| 5301 |
|
|
| 5302 |
449 |
documentName = LOCAL_REFERENCE_SERIALIZER.serialize(documentReference); |
| 5303 |
|
|
| 5304 |
449 |
result.add(documentName); |
| 5305 |
1428 |
} else if (macroBlock.getId().equalsIgnoreCase("velocity") |
| 5306 |
|
&& !StringUtils.isEmpty(macroBlock.getContent())) { |
| 5307 |
|
|
| 5308 |
980 |
result.addAll(getIncludedPagesForXWiki10Syntax(macroBlock.getContent(), context)); |
| 5309 |
|
} |
| 5310 |
|
} |
| 5311 |
|
|
| 5312 |
3810 |
return result; |
| 5313 |
|
} |
| 5314 |
|
} |
| 5315 |
|
|
| |
|
| 71.4% |
Uncovered Elements: 4 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 5316 |
983 |
private List<String> getIncludedPagesForXWiki10Syntax(String content, XWikiContext context)... |
| 5317 |
|
{ |
| 5318 |
983 |
try { |
| 5319 |
983 |
String pattern = "#include(Topic|InContext|Form|Macros|parseGroovyFromPage)\\([\"'](.*?)[\"']\\)"; |
| 5320 |
983 |
List<String> list = context.getUtil().getUniqueMatches(content, pattern, 2); |
| 5321 |
986 |
for (int i = 0; i < list.size(); i++) { |
| 5322 |
3 |
String name = list.get(i); |
| 5323 |
3 |
if (name.indexOf('.') == -1) { |
| 5324 |
0 |
list.set(i, getSpace() + "." + name); |
| 5325 |
|
} |
| 5326 |
|
} |
| 5327 |
|
|
| 5328 |
983 |
return list; |
| 5329 |
|
} catch (Exception e) { |
| 5330 |
0 |
LOGGER.error("Failed to extract include target from provided content [" + content + "]", e); |
| 5331 |
|
|
| 5332 |
0 |
return null; |
| 5333 |
|
} |
| 5334 |
|
} |
| 5335 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5336 |
0 |
public List<String> getIncludedMacros(XWikiContext context)... |
| 5337 |
|
{ |
| 5338 |
0 |
return context.getWiki().getIncludedMacros(getSpace(), getContent(), context); |
| 5339 |
|
} |
| 5340 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5341 |
0 |
public String displayRendered(PropertyClass pclass, String prefix, BaseCollection object, XWikiContext context)... |
| 5342 |
|
throws XWikiException |
| 5343 |
|
{ |
| 5344 |
0 |
String result = pclass.displayView(pclass.getName(), prefix, object, context); |
| 5345 |
0 |
return getRenderedContent(result, Syntax.XWIKI_1_0.toIdString(), context); |
| 5346 |
|
} |
| 5347 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 5348 |
326 |
public String displayView(PropertyClass pclass, String prefix, BaseCollection object, XWikiContext context)... |
| 5349 |
|
{ |
| 5350 |
326 |
return (pclass == null) ? "" : pclass.displayView(pclass.getName(), prefix, object, context); |
| 5351 |
|
} |
| 5352 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 5353 |
2034 |
public String displayEdit(PropertyClass pclass, String prefix, BaseCollection object, XWikiContext context)... |
| 5354 |
|
{ |
| 5355 |
2034 |
return (pclass == null) ? "" : pclass.displayEdit(pclass.getName(), prefix, object, context); |
| 5356 |
|
} |
| 5357 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 5358 |
0 |
public String displayHidden(PropertyClass pclass, String prefix, BaseCollection object, XWikiContext context)... |
| 5359 |
|
{ |
| 5360 |
0 |
return (pclass == null) ? "" : pclass.displayHidden(pclass.getName(), prefix, object, context); |
| 5361 |
|
} |
| 5362 |
|
|
| 5363 |
|
|
| 5364 |
|
@param |
| 5365 |
|
@return@link |
| 5366 |
|
|
| |
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 5367 |
5153 |
public XWikiAttachment getAttachment(String filename)... |
| 5368 |
|
{ |
| 5369 |
5153 |
for (XWikiAttachment attach : getAttachmentList()) { |
| 5370 |
30355 |
if (attach.getFilename().equals(filename)) { |
| 5371 |
4417 |
return attach; |
| 5372 |
|
} |
| 5373 |
|
} |
| 5374 |
|
|
| 5375 |
736 |
for (XWikiAttachment attach : getAttachmentList()) { |
| 5376 |
110 |
if (attach.getFilename().startsWith(filename + ".")) { |
| 5377 |
0 |
return attach; |
| 5378 |
|
} |
| 5379 |
|
} |
| 5380 |
|
|
| 5381 |
736 |
return null; |
| 5382 |
|
} |
| 5383 |
|
|
| 5384 |
|
|
| 5385 |
|
|
| 5386 |
|
|
| 5387 |
|
@param |
| 5388 |
|
@since |
| 5389 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5390 |
472 |
public void addAttachment(XWikiAttachment attachment)... |
| 5391 |
|
{ |
| 5392 |
472 |
attachment.setDoc(this); |
| 5393 |
472 |
getAttachmentList().add(attachment); |
| 5394 |
|
} |
| 5395 |
|
|
| 5396 |
|
|
| 5397 |
|
@deprecated@link |
| 5398 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 5399 |
5 |
@Deprecated... |
| 5400 |
|
public XWikiAttachment addAttachment(String fileName, byte[] content, XWikiContext context) throws XWikiException |
| 5401 |
|
{ |
| 5402 |
5 |
try { |
| 5403 |
5 |
return addAttachment(fileName, new ByteArrayInputStream(content != null ? content : new byte[0]), context); |
| 5404 |
|
} catch (IOException e) { |
| 5405 |
0 |
throw new XWikiException(XWikiException.MODULE_XWIKI_DOC, XWikiException.ERROR_XWIKI_UNKNOWN, |
| 5406 |
|
"Failed to set Attachment content", e); |
| 5407 |
|
} |
| 5408 |
|
} |
| 5409 |
|
|
| |
|
| 93.3% |
Uncovered Elements: 1 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 5410 |
16 |
public XWikiAttachment addAttachment(String fileName, InputStream content, XWikiContext context)... |
| 5411 |
|
throws XWikiException, IOException |
| 5412 |
|
{ |
| 5413 |
16 |
int i = fileName.indexOf('\\'); |
| 5414 |
16 |
if (i == -1) { |
| 5415 |
16 |
i = fileName.indexOf('/'); |
| 5416 |
|
} |
| 5417 |
|
|
| 5418 |
16 |
String filename = fileName.substring(i + 1); |
| 5419 |
|
|
| 5420 |
16 |
XWikiAttachment attachment = getAttachment(filename); |
| 5421 |
16 |
if (attachment == null) { |
| 5422 |
12 |
attachment = new XWikiAttachment(this, filename); |
| 5423 |
|
|
| 5424 |
|
|
| 5425 |
12 |
getAttachmentList().add(attachment); |
| 5426 |
|
} |
| 5427 |
|
|
| 5428 |
16 |
attachment.setContent(content); |
| 5429 |
16 |
attachment.setAuthorReference(context.getUserReference()); |
| 5430 |
|
|
| 5431 |
16 |
return attachment; |
| 5432 |
|
} |
| 5433 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5434 |
0 |
public BaseObject getFirstObject(String fieldname)... |
| 5435 |
|
{ |
| 5436 |
|
|
| 5437 |
|
|
| 5438 |
|
|
| 5439 |
0 |
return getFirstObject(fieldname, null); |
| 5440 |
|
} |
| 5441 |
|
|
| |
|
| 76% |
Uncovered Elements: 6 (25) |
Complexity: 8 |
Complexity Density: 0.53 |
|
| 5442 |
669 |
public BaseObject getFirstObject(String fieldname, XWikiContext context)... |
| 5443 |
|
{ |
| 5444 |
669 |
Collection<List<BaseObject>> objectscoll = getXObjects().values(); |
| 5445 |
668 |
if (objectscoll == null) { |
| 5446 |
0 |
return null; |
| 5447 |
|
} |
| 5448 |
|
|
| 5449 |
667 |
for (List<BaseObject> objects : objectscoll) { |
| 5450 |
1411 |
for (BaseObject obj : objects) { |
| 5451 |
1411 |
if (obj != null) { |
| 5452 |
1411 |
BaseClass bclass = obj.getXClass(context); |
| 5453 |
1410 |
if (bclass != null) { |
| 5454 |
1411 |
Set<String> set = bclass.getPropertyList(); |
| 5455 |
1411 |
if ((set != null) && set.contains(fieldname)) { |
| 5456 |
667 |
return obj; |
| 5457 |
|
} |
| 5458 |
|
} |
| 5459 |
744 |
Set<String> set = obj.getPropertyList(); |
| 5460 |
744 |
if ((set != null) && set.contains(fieldname)) { |
| 5461 |
0 |
return obj; |
| 5462 |
|
} |
| 5463 |
|
} |
| 5464 |
|
} |
| 5465 |
|
} |
| 5466 |
|
|
| 5467 |
2 |
return null; |
| 5468 |
|
} |
| 5469 |
|
|
| 5470 |
|
|
| 5471 |
|
@since |
| 5472 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5473 |
0 |
public void setProperty(EntityReference classReference, String fieldName, BaseProperty value)... |
| 5474 |
|
{ |
| 5475 |
0 |
BaseObject bobject = prepareXObject(classReference); |
| 5476 |
0 |
bobject.safeput(fieldName, value); |
| 5477 |
|
} |
| 5478 |
|
|
| 5479 |
|
|
| 5480 |
|
@deprecated@link |
| 5481 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5482 |
0 |
@Deprecated... |
| 5483 |
|
public void setProperty(String className, String fieldName, BaseProperty value) |
| 5484 |
|
{ |
| 5485 |
0 |
setProperty(getXClassEntityReferenceResolver().resolve(className, EntityType.DOCUMENT, getDocumentReference()), |
| 5486 |
|
fieldName, value); |
| 5487 |
|
} |
| 5488 |
|
|
| 5489 |
|
|
| 5490 |
|
@since |
| 5491 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 5492 |
29 |
public int getIntValue(DocumentReference classReference, String fieldName)... |
| 5493 |
|
{ |
| 5494 |
29 |
BaseObject obj = getXObject(classReference, 0); |
| 5495 |
29 |
if (obj == null) { |
| 5496 |
12 |
return 0; |
| 5497 |
|
} |
| 5498 |
|
|
| 5499 |
17 |
return obj.getIntValue(fieldName); |
| 5500 |
|
} |
| 5501 |
|
|
| 5502 |
|
|
| 5503 |
|
@deprecated@link |
| 5504 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5505 |
0 |
@Deprecated... |
| 5506 |
|
public int getIntValue(String className, String fieldName) |
| 5507 |
|
{ |
| 5508 |
0 |
return getIntValue(resolveClassReference(className), fieldName); |
| 5509 |
|
} |
| 5510 |
|
|
| 5511 |
|
|
| 5512 |
|
@since |
| 5513 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 5514 |
0 |
public long getLongValue(DocumentReference classReference, String fieldName)... |
| 5515 |
|
{ |
| 5516 |
0 |
BaseObject obj = getXObject(classReference, 0); |
| 5517 |
0 |
if (obj == null) { |
| 5518 |
0 |
return 0; |
| 5519 |
|
} |
| 5520 |
|
|
| 5521 |
0 |
return obj.getLongValue(fieldName); |
| 5522 |
|
} |
| 5523 |
|
|
| 5524 |
|
|
| 5525 |
|
@deprecated@link |
| 5526 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5527 |
0 |
@Deprecated... |
| 5528 |
|
public long getLongValue(String className, String fieldName) |
| 5529 |
|
{ |
| 5530 |
0 |
return getLongValue(resolveClassReference(className), fieldName); |
| 5531 |
|
} |
| 5532 |
|
|
| 5533 |
|
|
| 5534 |
|
@since |
| 5535 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5536 |
0 |
public String getStringValue(EntityReference classReference, String fieldName)... |
| 5537 |
|
{ |
| 5538 |
0 |
return getStringValue(resolveClassReference(classReference), fieldName); |
| 5539 |
|
} |
| 5540 |
|
|
| 5541 |
|
|
| 5542 |
|
@since |
| 5543 |
|
|
| |
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 5544 |
586 |
public String getStringValue(DocumentReference classReference, String fieldName)... |
| 5545 |
|
{ |
| 5546 |
586 |
BaseObject obj = getXObject(classReference); |
| 5547 |
586 |
if (obj == null) { |
| 5548 |
3 |
return ""; |
| 5549 |
|
} |
| 5550 |
|
|
| 5551 |
583 |
String result = obj.getStringValue(fieldName); |
| 5552 |
583 |
if (result.equals(" ")) { |
| 5553 |
0 |
return ""; |
| 5554 |
|
} else { |
| 5555 |
581 |
return result; |
| 5556 |
|
} |
| 5557 |
|
} |
| 5558 |
|
|
| 5559 |
|
|
| 5560 |
|
@deprecated@link |
| 5561 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5562 |
3 |
@Deprecated... |
| 5563 |
|
public String getStringValue(String className, String fieldName) |
| 5564 |
|
{ |
| 5565 |
3 |
return getStringValue(resolveClassReference(className), fieldName); |
| 5566 |
|
} |
| 5567 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 5568 |
0 |
public int getIntValue(String fieldName)... |
| 5569 |
|
{ |
| 5570 |
0 |
BaseObject object = getFirstObject(fieldName, null); |
| 5571 |
0 |
if (object == null) { |
| 5572 |
0 |
return 0; |
| 5573 |
|
} else { |
| 5574 |
0 |
return object.getIntValue(fieldName); |
| 5575 |
|
} |
| 5576 |
|
} |
| 5577 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 5578 |
0 |
public long getLongValue(String fieldName)... |
| 5579 |
|
{ |
| 5580 |
0 |
BaseObject object = getFirstObject(fieldName, null); |
| 5581 |
0 |
if (object == null) { |
| 5582 |
0 |
return 0; |
| 5583 |
|
} else { |
| 5584 |
0 |
return object.getLongValue(fieldName); |
| 5585 |
|
} |
| 5586 |
|
} |
| 5587 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 5588 |
0 |
public String getStringValue(String fieldName)... |
| 5589 |
|
{ |
| 5590 |
0 |
BaseObject object = getFirstObject(fieldName, null); |
| 5591 |
0 |
if (object == null) { |
| 5592 |
0 |
return ""; |
| 5593 |
|
} |
| 5594 |
|
|
| 5595 |
0 |
String result = object.getStringValue(fieldName); |
| 5596 |
0 |
if (result.equals(" ")) { |
| 5597 |
0 |
return ""; |
| 5598 |
|
} else { |
| 5599 |
0 |
return result; |
| 5600 |
|
} |
| 5601 |
|
} |
| 5602 |
|
|
| 5603 |
|
|
| 5604 |
|
@since |
| 5605 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5606 |
20 |
public void setStringValue(EntityReference classReference, String fieldName, String value)... |
| 5607 |
|
{ |
| 5608 |
20 |
BaseObject bobject = prepareXObject(classReference); |
| 5609 |
20 |
bobject.setStringValue(fieldName, value); |
| 5610 |
|
} |
| 5611 |
|
|
| 5612 |
|
|
| 5613 |
|
@deprecated@link |
| 5614 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5615 |
19 |
@Deprecated... |
| 5616 |
|
public void setStringValue(String className, String fieldName, String value) |
| 5617 |
|
{ |
| 5618 |
19 |
setStringValue( |
| 5619 |
|
getXClassEntityReferenceResolver().resolve(className, EntityType.DOCUMENT, getDocumentReference()), |
| 5620 |
|
fieldName, value); |
| 5621 |
|
} |
| 5622 |
|
|
| 5623 |
|
|
| 5624 |
|
@since |
| 5625 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 5626 |
0 |
public List getListValue(DocumentReference classReference, String fieldName)... |
| 5627 |
|
{ |
| 5628 |
0 |
BaseObject obj = getXObject(classReference); |
| 5629 |
0 |
if (obj == null) { |
| 5630 |
0 |
return new ArrayList(); |
| 5631 |
|
} |
| 5632 |
|
|
| 5633 |
0 |
return obj.getListValue(fieldName); |
| 5634 |
|
} |
| 5635 |
|
|
| 5636 |
|
|
| 5637 |
|
@deprecated@link |
| 5638 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5639 |
0 |
@Deprecated... |
| 5640 |
|
public List getListValue(String className, String fieldName) |
| 5641 |
|
{ |
| 5642 |
0 |
return getListValue(resolveClassReference(className), fieldName); |
| 5643 |
|
} |
| 5644 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 5645 |
0 |
public List getListValue(String fieldName)... |
| 5646 |
|
{ |
| 5647 |
0 |
BaseObject object = getFirstObject(fieldName, null); |
| 5648 |
0 |
if (object == null) { |
| 5649 |
0 |
return new ArrayList(); |
| 5650 |
|
} |
| 5651 |
|
|
| 5652 |
0 |
return object.getListValue(fieldName); |
| 5653 |
|
} |
| 5654 |
|
|
| 5655 |
|
|
| 5656 |
|
@since |
| 5657 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5658 |
8 |
public void setStringListValue(EntityReference classReference, String fieldName, List value)... |
| 5659 |
|
{ |
| 5660 |
8 |
BaseObject bobject = prepareXObject(classReference); |
| 5661 |
8 |
bobject.setStringListValue(fieldName, value); |
| 5662 |
|
} |
| 5663 |
|
|
| 5664 |
|
|
| 5665 |
|
@deprecated@link |
| 5666 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5667 |
8 |
@Deprecated... |
| 5668 |
|
public void setStringListValue(String className, String fieldName, List value) |
| 5669 |
|
{ |
| 5670 |
8 |
setStringListValue( |
| 5671 |
|
getXClassEntityReferenceResolver().resolve(className, EntityType.DOCUMENT, getDocumentReference()), |
| 5672 |
|
fieldName, value); |
| 5673 |
|
} |
| 5674 |
|
|
| 5675 |
|
|
| 5676 |
|
@since |
| 5677 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5678 |
20 |
public void setDBStringListValue(EntityReference classReference, String fieldName, List value)... |
| 5679 |
|
{ |
| 5680 |
20 |
BaseObject bobject = prepareXObject(classReference); |
| 5681 |
20 |
bobject.setDBStringListValue(fieldName, value); |
| 5682 |
|
} |
| 5683 |
|
|
| 5684 |
|
|
| 5685 |
|
@deprecated@link |
| 5686 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5687 |
20 |
@Deprecated... |
| 5688 |
|
public void setDBStringListValue(String className, String fieldName, List value) |
| 5689 |
|
{ |
| 5690 |
20 |
setDBStringListValue( |
| 5691 |
|
getXClassEntityReferenceResolver().resolve(className, EntityType.DOCUMENT, getDocumentReference()), |
| 5692 |
|
fieldName, value); |
| 5693 |
|
} |
| 5694 |
|
|
| 5695 |
|
|
| 5696 |
|
@since |
| 5697 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5698 |
0 |
public void setLargeStringValue(EntityReference classReference, String fieldName, String value)... |
| 5699 |
|
{ |
| 5700 |
0 |
BaseObject bobject = prepareXObject(classReference); |
| 5701 |
0 |
bobject.setLargeStringValue(fieldName, value); |
| 5702 |
|
} |
| 5703 |
|
|
| 5704 |
|
|
| 5705 |
|
@deprecated@link |
| 5706 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5707 |
0 |
@Deprecated... |
| 5708 |
|
public void setLargeStringValue(String className, String fieldName, String value) |
| 5709 |
|
{ |
| 5710 |
0 |
setLargeStringValue( |
| 5711 |
|
getXClassEntityReferenceResolver().resolve(className, EntityType.DOCUMENT, getDocumentReference()), |
| 5712 |
|
fieldName, value); |
| 5713 |
|
} |
| 5714 |
|
|
| 5715 |
|
|
| 5716 |
|
@since |
| 5717 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5718 |
0 |
public void setIntValue(EntityReference classReference, String fieldName, int value)... |
| 5719 |
|
{ |
| 5720 |
0 |
BaseObject bobject = prepareXObject(classReference); |
| 5721 |
0 |
bobject.setIntValue(fieldName, value); |
| 5722 |
|
} |
| 5723 |
|
|
| 5724 |
|
|
| 5725 |
|
@deprecated@link |
| 5726 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5727 |
0 |
@Deprecated... |
| 5728 |
|
public void setIntValue(String className, String fieldName, int value) |
| 5729 |
|
{ |
| 5730 |
0 |
setIntValue(getXClassEntityReferenceResolver().resolve(className, EntityType.DOCUMENT, getDocumentReference()), |
| 5731 |
|
fieldName, value); |
| 5732 |
|
} |
| 5733 |
|
|
| 5734 |
|
|
| 5735 |
|
|
| 5736 |
|
|
| 5737 |
|
@deprecated@link |
| 5738 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5739 |
61975 |
@Deprecated... |
| 5740 |
|
public String getDatabase() |
| 5741 |
|
{ |
| 5742 |
61973 |
return getDocumentReference().getWikiReference().getName(); |
| 5743 |
|
} |
| 5744 |
|
|
| 5745 |
|
|
| 5746 |
|
|
| 5747 |
|
|
| 5748 |
|
@deprecated@link |
| 5749 |
|
|
| |
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 5750 |
3836 |
@Deprecated... |
| 5751 |
|
public void setDatabase(String database) |
| 5752 |
|
{ |
| 5753 |
3836 |
if (database != null) { |
| 5754 |
3836 |
DocumentReference reference = getDocumentReference(); |
| 5755 |
3836 |
WikiReference wiki = reference.getWikiReference(); |
| 5756 |
3836 |
WikiReference newWiki = new WikiReference(database); |
| 5757 |
3836 |
if (!newWiki.equals(wiki)) { |
| 5758 |
1 |
setDocumentReferenceInternal(reference.replaceParent(wiki, newWiki)); |
| 5759 |
|
} |
| 5760 |
|
} |
| 5761 |
|
} |
| 5762 |
|
|
| 5763 |
|
|
| 5764 |
|
|
| 5765 |
|
|
| 5766 |
|
@deprecated@link |
| 5767 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5768 |
21679 |
@Deprecated... |
| 5769 |
|
public String getLanguage() |
| 5770 |
|
{ |
| 5771 |
21680 |
return getLocale().toString(); |
| 5772 |
|
} |
| 5773 |
|
|
| 5774 |
|
|
| 5775 |
|
|
| 5776 |
|
|
| 5777 |
|
@deprecated@link |
| 5778 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5779 |
4113 |
@Deprecated... |
| 5780 |
|
public void setLanguage(String language) |
| 5781 |
|
{ |
| 5782 |
4115 |
setLocale(LocaleUtils.toLocale(Util.normalizeLanguage(language), Locale.ROOT)); |
| 5783 |
|
} |
| 5784 |
|
|
| 5785 |
|
|
| 5786 |
|
@return |
| 5787 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 5788 |
1247687 |
public Locale getLocale()... |
| 5789 |
|
{ |
| 5790 |
1247668 |
return this.locale != null ? this.locale : Locale.ROOT; |
| 5791 |
|
} |
| 5792 |
|
|
| 5793 |
|
|
| 5794 |
|
@param |
| 5795 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 5796 |
42627 |
public void setLocale(Locale locale)... |
| 5797 |
|
{ |
| 5798 |
42631 |
this.locale = locale; |
| 5799 |
|
|
| 5800 |
42631 |
setMetaDataDirty(true); |
| 5801 |
|
|
| 5802 |
|
|
| 5803 |
|
|
| 5804 |
42632 |
this.keyCache = null; |
| 5805 |
42630 |
this.localKeyCache = null; |
| 5806 |
|
} |
| 5807 |
|
|
| 5808 |
|
|
| 5809 |
|
|
| 5810 |
|
|
| 5811 |
|
@deprecated@link |
| 5812 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5813 |
8792 |
@Deprecated... |
| 5814 |
|
public String getDefaultLanguage() |
| 5815 |
|
{ |
| 5816 |
8792 |
return getDefaultLocale().toString(); |
| 5817 |
|
} |
| 5818 |
|
|
| 5819 |
|
|
| 5820 |
|
|
| 5821 |
|
|
| 5822 |
|
@deprecated@link |
| 5823 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5824 |
3856 |
@Deprecated... |
| 5825 |
|
public void setDefaultLanguage(String defaultLanguage) |
| 5826 |
|
{ |
| 5827 |
3856 |
setDefaultLocale(LocaleUtils.toLocale(defaultLanguage, Locale.ROOT)); |
| 5828 |
|
} |
| 5829 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 5830 |
117603 |
public Locale getDefaultLocale()... |
| 5831 |
|
{ |
| 5832 |
117589 |
return this.defaultLocale != null ? this.defaultLocale : Locale.ROOT; |
| 5833 |
|
} |
| 5834 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5835 |
42971 |
public void setDefaultLocale(Locale defaultLocale)... |
| 5836 |
|
{ |
| 5837 |
42977 |
this.defaultLocale = defaultLocale; |
| 5838 |
|
|
| 5839 |
42977 |
setMetaDataDirty(true); |
| 5840 |
|
} |
| 5841 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 5842 |
59874 |
public int getTranslation()... |
| 5843 |
|
{ |
| 5844 |
59880 |
return getLocale().equals(Locale.ROOT) ? 0 : 1; |
| 5845 |
|
} |
| 5846 |
|
|
| 5847 |
|
|
| 5848 |
|
|
| 5849 |
|
|
| 5850 |
|
@deprecated@link |
| 5851 |
|
|
| 5852 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 5853 |
3644 |
@Deprecated... |
| 5854 |
|
public void setTranslation(int translation) |
| 5855 |
|
{ |
| 5856 |
|
|
| 5857 |
|
} |
| 5858 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5859 |
158 |
public String getTranslatedContent(XWikiContext context) throws XWikiException... |
| 5860 |
|
{ |
| 5861 |
158 |
String language = context.getWiki().getLanguagePreference(context); |
| 5862 |
|
|
| 5863 |
158 |
return getTranslatedContent(language, context); |
| 5864 |
|
} |
| 5865 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5866 |
158 |
public String getTranslatedContent(String locale, XWikiContext context) throws XWikiException... |
| 5867 |
|
{ |
| 5868 |
158 |
XWikiDocument tdoc = getTranslatedDocument(locale, context); |
| 5869 |
158 |
return tdoc.getContent(); |
| 5870 |
|
} |
| 5871 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 5872 |
59387 |
public XWikiDocument getTranslatedDocument(XWikiContext context) throws XWikiException... |
| 5873 |
|
{ |
| 5874 |
59396 |
String locale = context.getWiki().getLanguagePreference(context); |
| 5875 |
59385 |
return getTranslatedDocument(locale, context); |
| 5876 |
|
} |
| 5877 |
|
|
| 5878 |
|
|
| 5879 |
|
|
| 5880 |
|
|
| 5881 |
|
|
| 5882 |
|
|
| 5883 |
|
@param |
| 5884 |
|
@param |
| 5885 |
|
@return |
| 5886 |
|
@throws |
| 5887 |
|
@deprecated@link |
| 5888 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5889 |
59591 |
@Deprecated... |
| 5890 |
|
public XWikiDocument getTranslatedDocument(String language, XWikiContext context) throws XWikiException |
| 5891 |
|
{ |
| 5892 |
59618 |
return getTranslatedDocument(LocaleUtils.toLocale(language, Locale.ROOT), context); |
| 5893 |
|
} |
| 5894 |
|
|
| 5895 |
|
|
| 5896 |
|
|
| 5897 |
|
|
| 5898 |
|
|
| 5899 |
|
|
| 5900 |
|
@param |
| 5901 |
|
@param |
| 5902 |
|
@return |
| 5903 |
|
@throws |
| 5904 |
|
|
| |
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 6 |
Complexity Density: 0.75 |
|
| 5905 |
59749 |
public XWikiDocument getTranslatedDocument(Locale locale, XWikiContext context) throws XWikiException... |
| 5906 |
|
{ |
| 5907 |
59747 |
XWikiDocument tdoc = this; |
| 5908 |
|
|
| 5909 |
59745 |
if (locale != null && !locale.equals(Locale.ROOT) && !locale.equals(getDefaultLocale())) { |
| 5910 |
50626 |
try { |
| 5911 |
50625 |
tdoc = context.getWiki().getDocument(new DocumentReference(getDocumentReference(), locale), context); |
| 5912 |
|
|
| 5913 |
50644 |
if (tdoc.isNew()) { |
| 5914 |
50462 |
tdoc = this; |
| 5915 |
|
} |
| 5916 |
|
} catch (Exception e) { |
| 5917 |
0 |
tdoc = this; |
| 5918 |
|
} |
| 5919 |
|
} |
| 5920 |
|
|
| 5921 |
59762 |
return tdoc; |
| 5922 |
|
} |
| 5923 |
|
|
| 5924 |
|
|
| 5925 |
|
@deprecated@link |
| 5926 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5927 |
22 |
@Deprecated... |
| 5928 |
|
public String getRealLanguage(XWikiContext context) throws XWikiException |
| 5929 |
|
{ |
| 5930 |
22 |
return getRealLanguage(); |
| 5931 |
|
} |
| 5932 |
|
|
| 5933 |
|
|
| 5934 |
|
@inheritDoc |
| 5935 |
|
|
| 5936 |
|
@see |
| 5937 |
|
@deprecated@link |
| 5938 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 5939 |
374 |
@Override... |
| 5940 |
|
@Deprecated |
| 5941 |
|
public String getRealLanguage() |
| 5942 |
|
{ |
| 5943 |
374 |
String lang = getLanguage(); |
| 5944 |
374 |
if (lang.equals("")) { |
| 5945 |
368 |
return getDefaultLanguage(); |
| 5946 |
|
} else { |
| 5947 |
6 |
return lang; |
| 5948 |
|
} |
| 5949 |
|
} |
| 5950 |
|
|
| 5951 |
|
|
| 5952 |
|
@return |
| 5953 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 5954 |
11094 |
public Locale getRealLocale()... |
| 5955 |
|
{ |
| 5956 |
11094 |
Locale locale = getLocale(); |
| 5957 |
11094 |
if (locale.equals(Locale.ROOT)) { |
| 5958 |
10976 |
locale = getDefaultLocale(); |
| 5959 |
|
} |
| 5960 |
|
|
| 5961 |
11094 |
return locale; |
| 5962 |
|
} |
| 5963 |
|
|
| 5964 |
|
|
| 5965 |
|
@deprecated@link |
| 5966 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5967 |
5333 |
@Deprecated... |
| 5968 |
|
public List<String> getTranslationList(XWikiContext context) throws XWikiException |
| 5969 |
|
{ |
| 5970 |
5333 |
return getStore().getTranslationList(this, context); |
| 5971 |
|
} |
| 5972 |
|
|
| 5973 |
|
|
| 5974 |
|
|
| 5975 |
|
|
| 5976 |
|
@param |
| 5977 |
|
@return |
| 5978 |
|
@throws |
| 5979 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 5980 |
4511 |
public List<Locale> getTranslationLocales(XWikiContext context) throws XWikiException... |
| 5981 |
|
{ |
| 5982 |
4511 |
List<String> translations = getTranslationList(context); |
| 5983 |
|
|
| 5984 |
4510 |
List<Locale> locales = new ArrayList<Locale>(translations.size()); |
| 5985 |
4510 |
for (String translationString : translations) { |
| 5986 |
863 |
locales.add(LocaleUtils.toLocale(translationString)); |
| 5987 |
|
} |
| 5988 |
|
|
| 5989 |
4511 |
return locales; |
| 5990 |
|
} |
| 5991 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5992 |
0 |
public List<Delta> getXMLDiff(XWikiDocument fromDoc, XWikiDocument toDoc, XWikiContext context)... |
| 5993 |
|
throws XWikiException, DifferentiationFailedException |
| 5994 |
|
{ |
| 5995 |
0 |
return getDeltas( |
| 5996 |
|
Diff.diff(ToString.stringToArray(fromDoc.toXML(context)), ToString.stringToArray(toDoc.toXML(context)))); |
| 5997 |
|
} |
| 5998 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 5999 |
1 |
public List<Delta> getContentDiff(XWikiDocument fromDoc, XWikiDocument toDoc, XWikiContext context)... |
| 6000 |
|
throws XWikiException, DifferentiationFailedException |
| 6001 |
|
{ |
| 6002 |
1 |
return getDeltas( |
| 6003 |
|
Diff.diff(ToString.stringToArray(fromDoc.getContent()), ToString.stringToArray(toDoc.getContent()))); |
| 6004 |
|
} |
| 6005 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 6006 |
0 |
public List<Delta> getContentDiff(String fromRev, String toRev, XWikiContext context)... |
| 6007 |
|
throws XWikiException, DifferentiationFailedException |
| 6008 |
|
{ |
| 6009 |
0 |
XWikiDocument fromDoc = context.getWiki().getDocument(this, fromRev, context); |
| 6010 |
0 |
XWikiDocument toDoc = context.getWiki().getDocument(this, toRev, context); |
| 6011 |
0 |
return getContentDiff(fromDoc, toDoc, context); |
| 6012 |
|
} |
| 6013 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 6014 |
0 |
public List<Delta> getContentDiff(String fromRev, XWikiContext context)... |
| 6015 |
|
throws XWikiException, DifferentiationFailedException |
| 6016 |
|
{ |
| 6017 |
0 |
XWikiDocument revdoc = context.getWiki().getDocument(this, fromRev, context); |
| 6018 |
0 |
return getContentDiff(revdoc, this, context); |
| 6019 |
|
} |
| 6020 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 6021 |
0 |
public List<Delta> getLastChanges(XWikiContext context) throws XWikiException, DifferentiationFailedException... |
| 6022 |
|
{ |
| 6023 |
0 |
Version version = getRCSVersion(); |
| 6024 |
0 |
try { |
| 6025 |
0 |
String prev = getDocumentArchive(context).getPrevVersion(version).toString(); |
| 6026 |
0 |
XWikiDocument prevDoc = context.getWiki().getDocument(this, prev, context); |
| 6027 |
|
|
| 6028 |
0 |
return getDeltas( |
| 6029 |
|
Diff.diff(ToString.stringToArray(prevDoc.getContent()), ToString.stringToArray(getContent()))); |
| 6030 |
|
} catch (Exception ex) { |
| 6031 |
0 |
LOGGER.debug("Exception getting differences from previous version: " + ex.getMessage()); |
| 6032 |
|
} |
| 6033 |
|
|
| 6034 |
0 |
return new ArrayList<Delta>(); |
| 6035 |
|
} |
| 6036 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 6037 |
0 |
public List<Delta> getRenderedContentDiff(XWikiDocument fromDoc, XWikiDocument toDoc, XWikiContext context)... |
| 6038 |
|
throws XWikiException, DifferentiationFailedException |
| 6039 |
|
{ |
| 6040 |
0 |
String originalContent = fromDoc.getRenderedContent(context); |
| 6041 |
0 |
String newContent = toDoc.getRenderedContent(context); |
| 6042 |
|
|
| 6043 |
0 |
return getDeltas(Diff.diff(ToString.stringToArray(originalContent), ToString.stringToArray(newContent))); |
| 6044 |
|
} |
| 6045 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 6046 |
0 |
public List<Delta> getRenderedContentDiff(String fromRev, String toRev, XWikiContext context)... |
| 6047 |
|
throws XWikiException, DifferentiationFailedException |
| 6048 |
|
{ |
| 6049 |
0 |
XWikiDocument fromDoc = context.getWiki().getDocument(this, fromRev, context); |
| 6050 |
0 |
XWikiDocument toDoc = context.getWiki().getDocument(this, toRev, context); |
| 6051 |
|
|
| 6052 |
0 |
return getRenderedContentDiff(fromDoc, toDoc, context); |
| 6053 |
|
} |
| 6054 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 6055 |
0 |
public List<Delta> getRenderedContentDiff(String fromRev, XWikiContext context)... |
| 6056 |
|
throws XWikiException, DifferentiationFailedException |
| 6057 |
|
{ |
| 6058 |
0 |
XWikiDocument revdoc = context.getWiki().getDocument(this, fromRev, context); |
| 6059 |
|
|
| 6060 |
0 |
return getRenderedContentDiff(revdoc, this, context); |
| 6061 |
|
} |
| 6062 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 6063 |
1 |
protected List<Delta> getDeltas(Revision rev)... |
| 6064 |
|
{ |
| 6065 |
1 |
List<Delta> list = new ArrayList<Delta>(); |
| 6066 |
2 |
for (int i = 0; i < rev.size(); i++) { |
| 6067 |
1 |
list.add(rev.getDelta(i)); |
| 6068 |
|
} |
| 6069 |
|
|
| 6070 |
1 |
return list; |
| 6071 |
|
} |
| 6072 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 6073 |
0 |
public List<MetaDataDiff> getMetaDataDiff(String fromRev, String toRev, XWikiContext context) throws XWikiException... |
| 6074 |
|
{ |
| 6075 |
0 |
XWikiDocument fromDoc = context.getWiki().getDocument(this, fromRev, context); |
| 6076 |
0 |
XWikiDocument toDoc = context.getWiki().getDocument(this, toRev, context); |
| 6077 |
|
|
| 6078 |
0 |
return getMetaDataDiff(fromDoc, toDoc, context); |
| 6079 |
|
} |
| 6080 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 6081 |
0 |
public List<MetaDataDiff> getMetaDataDiff(String fromRev, XWikiContext context) throws XWikiException... |
| 6082 |
|
{ |
| 6083 |
0 |
XWikiDocument revdoc = context.getWiki().getDocument(this, fromRev, context); |
| 6084 |
|
|
| 6085 |
0 |
return getMetaDataDiff(revdoc, this, context); |
| 6086 |
|
} |
| 6087 |
|
|
| |
|
| 69.6% |
Uncovered Elements: 14 (46) |
Complexity: 13 |
Complexity Density: 0.54 |
|
| 6088 |
5 |
public List<MetaDataDiff> getMetaDataDiff(XWikiDocument fromDoc, XWikiDocument toDoc, XWikiContext context)... |
| 6089 |
|
throws XWikiException |
| 6090 |
|
{ |
| 6091 |
5 |
List<MetaDataDiff> list = new ArrayList<MetaDataDiff>(); |
| 6092 |
|
|
| 6093 |
5 |
if (fromDoc == null || toDoc == null) { |
| 6094 |
0 |
return list; |
| 6095 |
|
} |
| 6096 |
|
|
| 6097 |
5 |
if (!fromDoc.getTitle().equals(toDoc.getTitle())) { |
| 6098 |
1 |
list.add(new MetaDataDiff("title", fromDoc.getTitle(), toDoc.getTitle())); |
| 6099 |
|
} |
| 6100 |
|
|
| 6101 |
5 |
if (ObjectUtils.notEqual(fromDoc.getRelativeParentReference(), toDoc.getRelativeParentReference())) { |
| 6102 |
1 |
list.add(new MetaDataDiff("parent", fromDoc.getParent(), toDoc.getParent())); |
| 6103 |
|
} |
| 6104 |
|
|
| 6105 |
5 |
if (ObjectUtils.notEqual(fromDoc.getAuthorReference(), toDoc.getAuthorReference())) { |
| 6106 |
4 |
list.add(new MetaDataDiff("author", fromDoc.getAuthor(), toDoc.getAuthor())); |
| 6107 |
|
} |
| 6108 |
|
|
| 6109 |
5 |
if (ObjectUtils.notEqual(fromDoc.getDocumentReference(), toDoc.getDocumentReference())) { |
| 6110 |
0 |
list.add(new MetaDataDiff("reference", fromDoc.getDocumentReference(), toDoc.getDocumentReference())); |
| 6111 |
|
} |
| 6112 |
|
|
| 6113 |
5 |
if (!fromDoc.getSpace().equals(toDoc.getSpace())) { |
| 6114 |
0 |
list.add(new MetaDataDiff("web", fromDoc.getSpace(), toDoc.getSpace())); |
| 6115 |
|
} |
| 6116 |
|
|
| 6117 |
5 |
if (!fromDoc.getName().equals(toDoc.getName())) { |
| 6118 |
0 |
list.add(new MetaDataDiff("name", fromDoc.getName(), toDoc.getName())); |
| 6119 |
|
} |
| 6120 |
|
|
| 6121 |
5 |
if (ObjectUtils.notEqual(fromDoc.getLocale(), toDoc.getLocale())) { |
| 6122 |
0 |
list.add(new MetaDataDiff("language", fromDoc.getLanguage(), toDoc.getLanguage())); |
| 6123 |
|
} |
| 6124 |
|
|
| 6125 |
5 |
if (ObjectUtils.notEqual(fromDoc.getDefaultLocale(), toDoc.getDefaultLocale())) { |
| 6126 |
2 |
list.add(new MetaDataDiff("defaultLanguage", fromDoc.getDefaultLanguage(), toDoc.getDefaultLanguage())); |
| 6127 |
|
} |
| 6128 |
|
|
| 6129 |
5 |
if (ObjectUtils.notEqual(fromDoc.getSyntax(), toDoc.getSyntax())) { |
| 6130 |
0 |
list.add(new MetaDataDiff("syntax", fromDoc.getSyntax(), toDoc.getSyntax())); |
| 6131 |
|
} |
| 6132 |
|
|
| 6133 |
5 |
if (fromDoc.isHidden() != toDoc.isHidden()) { |
| 6134 |
0 |
list.add(new MetaDataDiff("hidden", fromDoc.isHidden(), toDoc.isHidden())); |
| 6135 |
|
} |
| 6136 |
|
|
| 6137 |
5 |
return list; |
| 6138 |
|
} |
| 6139 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 6140 |
0 |
public List<List<ObjectDiff>> getObjectDiff(String fromRev, String toRev, XWikiContext context)... |
| 6141 |
|
throws XWikiException |
| 6142 |
|
{ |
| 6143 |
0 |
XWikiDocument fromDoc = context.getWiki().getDocument(this, fromRev, context); |
| 6144 |
0 |
XWikiDocument toDoc = context.getWiki().getDocument(this, toRev, context); |
| 6145 |
|
|
| 6146 |
0 |
return getObjectDiff(fromDoc, toDoc, context); |
| 6147 |
|
} |
| 6148 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 6149 |
0 |
public List<List<ObjectDiff>> getObjectDiff(String fromRev, XWikiContext context) throws XWikiException... |
| 6150 |
|
{ |
| 6151 |
0 |
XWikiDocument revdoc = context.getWiki().getDocument(this, fromRev, context); |
| 6152 |
|
|
| 6153 |
0 |
return getObjectDiff(revdoc, this, context); |
| 6154 |
|
} |
| 6155 |
|
|
| 6156 |
|
|
| 6157 |
|
|
| 6158 |
|
|
| 6159 |
|
|
| 6160 |
|
@param |
| 6161 |
|
@param |
| 6162 |
|
@param@link |
| 6163 |
|
@return |
| 6164 |
|
@link |
| 6165 |
|
|
| 6166 |
|
|
| 6167 |
|
|
| |
|
| 97.5% |
Uncovered Elements: 1 (40) |
Complexity: 7 |
Complexity Density: 0.25 |
|
| 6168 |
517 |
public List<List<ObjectDiff>> getObjectDiff(XWikiDocument fromDoc, XWikiDocument toDoc, XWikiContext context)... |
| 6169 |
|
{ |
| 6170 |
517 |
List<List<ObjectDiff>> difflist = new ArrayList<List<ObjectDiff>>(); |
| 6171 |
|
|
| 6172 |
|
|
| 6173 |
|
|
| 6174 |
|
|
| 6175 |
517 |
for (List<BaseObject> objects : fromDoc.getXObjects().values()) { |
| 6176 |
567 |
for (BaseObject originalObj : objects) { |
| 6177 |
|
|
| 6178 |
|
|
| 6179 |
691 |
if (originalObj != null) { |
| 6180 |
679 |
BaseObject newObj = toDoc.getXObject(originalObj.getXClassReference(), originalObj.getNumber()); |
| 6181 |
679 |
List<ObjectDiff> dlist; |
| 6182 |
679 |
if (newObj == null) { |
| 6183 |
|
|
| 6184 |
14 |
dlist = new BaseObject().getDiff(originalObj, context); |
| 6185 |
14 |
ObjectDiff deleteMarker = |
| 6186 |
|
new ObjectDiff(originalObj.getXClassReference(), originalObj.getNumber(), |
| 6187 |
|
originalObj.getGuid(), ObjectDiff.ACTION_OBJECTREMOVED, "", "", "", ""); |
| 6188 |
14 |
dlist.add(0, deleteMarker); |
| 6189 |
|
} else { |
| 6190 |
|
|
| 6191 |
665 |
dlist = newObj.getDiff(originalObj, context); |
| 6192 |
|
} |
| 6193 |
679 |
if (!dlist.isEmpty()) { |
| 6194 |
158 |
difflist.add(dlist); |
| 6195 |
|
} |
| 6196 |
|
} |
| 6197 |
|
} |
| 6198 |
|
} |
| 6199 |
|
|
| 6200 |
|
|
| 6201 |
517 |
for (List<BaseObject> objects : toDoc.getXObjects().values()) { |
| 6202 |
630 |
for (BaseObject newObj : objects) { |
| 6203 |
|
|
| 6204 |
|
|
| 6205 |
795 |
if (newObj != null) { |
| 6206 |
764 |
BaseObject originalObj = fromDoc.getXObject(newObj.getXClassReference(), newObj.getNumber()); |
| 6207 |
764 |
if (originalObj == null) { |
| 6208 |
|
|
| 6209 |
|
|
| 6210 |
99 |
originalObj = new BaseObject(); |
| 6211 |
99 |
originalObj.setXClassReference(newObj.getRelativeXClassReference()); |
| 6212 |
99 |
originalObj.setNumber(newObj.getNumber()); |
| 6213 |
99 |
originalObj.setGuid(newObj.getGuid()); |
| 6214 |
99 |
List<ObjectDiff> dlist = newObj.getDiff(originalObj, context); |
| 6215 |
99 |
ObjectDiff addMarker = new ObjectDiff(newObj.getXClassReference(), newObj.getNumber(), |
| 6216 |
|
newObj.getGuid(), ObjectDiff.ACTION_OBJECTADDED, "", "", "", ""); |
| 6217 |
99 |
dlist.add(0, addMarker); |
| 6218 |
99 |
if (!dlist.isEmpty()) { |
| 6219 |
99 |
difflist.add(dlist); |
| 6220 |
|
} |
| 6221 |
|
} |
| 6222 |
|
} |
| 6223 |
|
} |
| 6224 |
|
} |
| 6225 |
|
|
| 6226 |
517 |
return difflist; |
| 6227 |
|
} |
| 6228 |
|
|
| |
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 6229 |
462 |
public List<List<ObjectDiff>> getClassDiff(XWikiDocument fromDoc, XWikiDocument toDoc, XWikiContext context)... |
| 6230 |
|
{ |
| 6231 |
462 |
List<List<ObjectDiff>> difflist = new ArrayList<List<ObjectDiff>>(); |
| 6232 |
462 |
BaseClass oldClass = fromDoc.getXClass(); |
| 6233 |
462 |
BaseClass newClass = toDoc.getXClass(); |
| 6234 |
|
|
| 6235 |
462 |
if ((newClass == null) && (oldClass == null)) { |
| 6236 |
0 |
return difflist; |
| 6237 |
|
} |
| 6238 |
|
|
| 6239 |
462 |
List<ObjectDiff> dlist = newClass.getDiff(oldClass, context); |
| 6240 |
462 |
if (!dlist.isEmpty()) { |
| 6241 |
14 |
difflist.add(dlist); |
| 6242 |
|
} |
| 6243 |
|
|
| 6244 |
462 |
return difflist; |
| 6245 |
|
} |
| 6246 |
|
|
| 6247 |
|
|
| 6248 |
|
@param |
| 6249 |
|
@param |
| 6250 |
|
@param |
| 6251 |
|
@return |
| 6252 |
|
|
| |
|
| 95.5% |
Uncovered Elements: 1 (22) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 6253 |
511 |
public List<AttachmentDiff> getAttachmentDiff(XWikiDocument fromDoc, XWikiDocument toDoc, XWikiContext context)... |
| 6254 |
|
{ |
| 6255 |
511 |
List<AttachmentDiff> difflist = new ArrayList<AttachmentDiff>(); |
| 6256 |
511 |
for (XWikiAttachment origAttach : fromDoc.getAttachmentList()) { |
| 6257 |
81 |
String fileName = origAttach.getFilename(); |
| 6258 |
81 |
XWikiAttachment newAttach = toDoc.getAttachment(fileName); |
| 6259 |
81 |
if (newAttach == null) { |
| 6260 |
9 |
difflist.add(new AttachmentDiff(fileName, org.xwiki.diff.Delta.Type.DELETE, origAttach, newAttach)); |
| 6261 |
|
} else { |
| 6262 |
72 |
try { |
| 6263 |
72 |
if (!origAttach.equalsData(newAttach, context)) { |
| 6264 |
4 |
difflist |
| 6265 |
|
.add(new AttachmentDiff(fileName, org.xwiki.diff.Delta.Type.CHANGE, origAttach, newAttach)); |
| 6266 |
|
} |
| 6267 |
|
} catch (XWikiException e) { |
| 6268 |
0 |
LOGGER.error("Failed to compare attachments [{}] and [{}]", origAttach.getReference(), |
| 6269 |
|
newAttach.getReference(), e); |
| 6270 |
|
} |
| 6271 |
|
} |
| 6272 |
|
} |
| 6273 |
|
|
| 6274 |
511 |
for (XWikiAttachment newAttach : toDoc.getAttachmentList()) { |
| 6275 |
128 |
String fileName = newAttach.getFilename(); |
| 6276 |
128 |
XWikiAttachment origAttach = fromDoc.getAttachment(fileName); |
| 6277 |
128 |
if (origAttach == null) { |
| 6278 |
56 |
difflist.add(new AttachmentDiff(fileName, org.xwiki.diff.Delta.Type.INSERT, origAttach, newAttach)); |
| 6279 |
|
} |
| 6280 |
|
} |
| 6281 |
|
|
| 6282 |
511 |
return difflist; |
| 6283 |
|
} |
| 6284 |
|
|
| 6285 |
|
|
| 6286 |
|
|
| 6287 |
|
|
| 6288 |
|
|
| 6289 |
|
@link |
| 6290 |
|
|
| 6291 |
|
@param |
| 6292 |
|
@param |
| 6293 |
|
@throws |
| 6294 |
|
@since |
| 6295 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6296 |
2 |
public void rename(DocumentReference newDocumentReference, XWikiContext context) throws XWikiException... |
| 6297 |
|
{ |
| 6298 |
2 |
rename(newDocumentReference, getBackLinkedReferences(context), context); |
| 6299 |
|
} |
| 6300 |
|
|
| 6301 |
|
|
| 6302 |
|
@deprecated@link |
| 6303 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6304 |
1 |
@Deprecated... |
| 6305 |
|
public void rename(String newDocumentName, XWikiContext context) throws XWikiException |
| 6306 |
|
{ |
| 6307 |
1 |
rename(newDocumentName, getBackLinkedPages(context), context); |
| 6308 |
|
} |
| 6309 |
|
|
| 6310 |
|
|
| 6311 |
|
|
| 6312 |
|
|
| 6313 |
|
|
| 6314 |
|
|
| 6315 |
|
|
| 6316 |
|
|
| 6317 |
|
|
| 6318 |
|
|
| 6319 |
|
|
| 6320 |
|
|
| 6321 |
|
|
| 6322 |
|
|
| 6323 |
|
|
| 6324 |
|
|
| 6325 |
|
|
| 6326 |
|
@param |
| 6327 |
|
@param |
| 6328 |
|
|
| 6329 |
|
@param |
| 6330 |
|
@throws |
| 6331 |
|
@since |
| 6332 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6333 |
2 |
public void rename(DocumentReference newDocumentReference, List<DocumentReference> backlinkDocumentReferences,... |
| 6334 |
|
XWikiContext context) throws XWikiException |
| 6335 |
|
{ |
| 6336 |
2 |
rename(newDocumentReference, backlinkDocumentReferences, getChildrenReferences(context), context); |
| 6337 |
|
} |
| 6338 |
|
|
| 6339 |
|
|
| 6340 |
|
@deprecated@link |
| 6341 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6342 |
1 |
@Deprecated... |
| 6343 |
|
public void rename(String newDocumentName, List<String> backlinkDocumentNames, XWikiContext context) |
| 6344 |
|
throws XWikiException |
| 6345 |
|
{ |
| 6346 |
1 |
rename(newDocumentName, backlinkDocumentNames, getChildren(context), context); |
| 6347 |
|
} |
| 6348 |
|
|
| 6349 |
|
|
| 6350 |
|
@link |
| 6351 |
|
|
| 6352 |
|
|
| 6353 |
|
@param |
| 6354 |
|
@param |
| 6355 |
|
|
| 6356 |
|
@param |
| 6357 |
|
|
| 6358 |
|
@param |
| 6359 |
|
@throws |
| 6360 |
|
@since |
| 6361 |
|
|
| |
|
| 82.8% |
Uncovered Elements: 10 (58) |
Complexity: 10 |
Complexity Density: 0.23 |
|
| 6362 |
5 |
public void rename(DocumentReference newDocumentReference, List<DocumentReference> backlinkDocumentReferences,... |
| 6363 |
|
List<DocumentReference> childDocumentReferences, XWikiContext context) throws XWikiException |
| 6364 |
|
{ |
| 6365 |
|
|
| 6366 |
|
|
| 6367 |
|
|
| 6368 |
|
|
| 6369 |
|
|
| 6370 |
5 |
if (isNew() || getDocumentReference().equals(newDocumentReference)) { |
| 6371 |
0 |
return; |
| 6372 |
|
} |
| 6373 |
|
|
| 6374 |
|
|
| 6375 |
5 |
XWiki xwiki = context.getWiki(); |
| 6376 |
|
|
| 6377 |
|
|
| 6378 |
5 |
xwiki.copyDocument(getDocumentReference(), newDocumentReference, false, context); |
| 6379 |
|
|
| 6380 |
|
|
| 6381 |
5 |
if (childDocumentReferences != null) { |
| 6382 |
5 |
for (DocumentReference childDocumentReference : childDocumentReferences) { |
| 6383 |
2 |
XWikiDocument childDocument = xwiki.getDocument(childDocumentReference, context); |
| 6384 |
2 |
String compactReference = getCompactEntityReferenceSerializer().serialize(newDocumentReference); |
| 6385 |
2 |
childDocument.setParent(compactReference); |
| 6386 |
2 |
String saveMessage = localizePlainOrKey("core.comment.renameParent", compactReference); |
| 6387 |
2 |
childDocument.setAuthorReference(context.getUserReference()); |
| 6388 |
2 |
xwiki.saveDocument(childDocument, saveMessage, true, context); |
| 6389 |
|
} |
| 6390 |
|
} |
| 6391 |
|
|
| 6392 |
|
|
| 6393 |
5 |
for (DocumentReference backlinkDocumentReference : backlinkDocumentReferences) { |
| 6394 |
3 |
XWikiDocument backlinkRootDocument = xwiki.getDocument(backlinkDocumentReference, context); |
| 6395 |
|
|
| 6396 |
|
|
| 6397 |
3 |
renameLinks(backlinkRootDocument, getDocumentReference(), newDocumentReference, context); |
| 6398 |
|
|
| 6399 |
|
|
| 6400 |
3 |
for (Locale locale : backlinkRootDocument.getTranslationLocales(context)) { |
| 6401 |
0 |
XWikiDocument backlinkDocument = backlinkRootDocument.getTranslatedDocument(locale, context); |
| 6402 |
|
|
| 6403 |
0 |
renameLinks(backlinkDocument, getDocumentReference(), newDocumentReference, context); |
| 6404 |
|
} |
| 6405 |
|
} |
| 6406 |
|
|
| 6407 |
|
|
| 6408 |
5 |
XWikiDocument newDocument = xwiki.getDocument(newDocumentReference, context); |
| 6409 |
|
|
| 6410 |
|
|
| 6411 |
|
|
| 6412 |
5 |
if (Utils.getContextComponentManager().hasComponent(BlockRenderer.class, getSyntax().toIdString())) { |
| 6413 |
|
|
| 6414 |
|
|
| 6415 |
4 |
LinkedResourceHelper linkedResourceHelper = Utils.getComponent(LinkedResourceHelper.class); |
| 6416 |
|
|
| 6417 |
4 |
DocumentReference oldDocumentReference = getDocumentReference(); |
| 6418 |
|
|
| 6419 |
4 |
XDOM newDocumentXDOM = newDocument.getXDOM(); |
| 6420 |
4 |
List<Block> blocks = linkedResourceHelper.getBlocks(newDocumentXDOM); |
| 6421 |
|
|
| 6422 |
|
|
| 6423 |
|
|
| 6424 |
4 |
boolean modified = false; |
| 6425 |
4 |
for (Block block : blocks) { |
| 6426 |
1 |
ResourceReference resourceReference = linkedResourceHelper.getResourceReference(block); |
| 6427 |
1 |
if (resourceReference == null) { |
| 6428 |
|
|
| 6429 |
0 |
continue; |
| 6430 |
|
} |
| 6431 |
|
|
| 6432 |
1 |
ResourceType resourceType = resourceReference.getType(); |
| 6433 |
|
|
| 6434 |
|
|
| 6435 |
1 |
if (!ResourceType.DOCUMENT.equals(resourceType) && !ResourceType.SPACE.equals(resourceType)) { |
| 6436 |
|
|
| 6437 |
0 |
continue; |
| 6438 |
|
} |
| 6439 |
|
|
| 6440 |
|
|
| 6441 |
1 |
EntityReference oldLinkReference = getResourceReferenceEntityReferenceResolver() |
| 6442 |
|
.resolve(resourceReference, null, oldDocumentReference); |
| 6443 |
|
|
| 6444 |
1 |
EntityReference newLinkReference = getResourceReferenceEntityReferenceResolver() |
| 6445 |
|
.resolve(resourceReference, null, newDocumentReference); |
| 6446 |
|
|
| 6447 |
|
|
| 6448 |
1 |
if (!newLinkReference.equals(oldLinkReference)) { |
| 6449 |
1 |
modified = true; |
| 6450 |
|
|
| 6451 |
|
|
| 6452 |
1 |
String serializedLinkReference = |
| 6453 |
|
getCompactWikiEntityReferenceSerializer().serialize(oldLinkReference, newDocumentReference); |
| 6454 |
|
|
| 6455 |
|
|
| 6456 |
1 |
linkedResourceHelper.setResourceReferenceString(block, serializedLinkReference); |
| 6457 |
|
} |
| 6458 |
|
} |
| 6459 |
|
|
| 6460 |
|
|
| 6461 |
4 |
if (modified) { |
| 6462 |
1 |
newDocument.setContent(newDocumentXDOM); |
| 6463 |
1 |
newDocument.setAuthorReference(context.getUserReference()); |
| 6464 |
1 |
xwiki.saveDocument(newDocument, context); |
| 6465 |
|
} |
| 6466 |
|
} |
| 6467 |
|
|
| 6468 |
|
|
| 6469 |
5 |
xwiki.deleteDocument(this, context); |
| 6470 |
|
|
| 6471 |
|
|
| 6472 |
|
|
| 6473 |
5 |
clone(newDocument); |
| 6474 |
|
} |
| 6475 |
|
|
| 6476 |
|
|
| 6477 |
|
|
| 6478 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 6479 |
3 |
private void renameLinks(XWikiDocument backlinkDocument, DocumentReference oldLink, DocumentReference newLink,... |
| 6480 |
|
XWikiContext context) throws XWikiException |
| 6481 |
|
{ |
| 6482 |
|
|
| 6483 |
|
|
| 6484 |
3 |
getOldRendering().renameLinks(backlinkDocument, oldLink, newLink, context); |
| 6485 |
|
|
| 6486 |
|
|
| 6487 |
3 |
if (backlinkDocument.isContentDirty()) { |
| 6488 |
3 |
String saveMessage = |
| 6489 |
|
localizePlainOrKey("core.comment.renameLink", getCompactEntityReferenceSerializer().serialize(newLink)); |
| 6490 |
3 |
backlinkDocument.setAuthorReference(context.getUserReference()); |
| 6491 |
3 |
context.getWiki().saveDocument(backlinkDocument, saveMessage, true, context); |
| 6492 |
|
} |
| 6493 |
|
} |
| 6494 |
|
|
| 6495 |
|
|
| 6496 |
|
@deprecated@link |
| 6497 |
|
|
| |
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 6498 |
1 |
@Deprecated... |
| 6499 |
|
public void rename(String newDocumentName, List<String> backlinkDocumentNames, List<String> childDocumentNames, |
| 6500 |
|
XWikiContext context) throws XWikiException |
| 6501 |
|
{ |
| 6502 |
1 |
List<DocumentReference> backlinkDocumentReferences = new ArrayList<DocumentReference>(); |
| 6503 |
1 |
for (String backlinkDocumentName : backlinkDocumentNames) { |
| 6504 |
0 |
backlinkDocumentReferences.add(getCurrentMixedDocumentReferenceResolver().resolve(backlinkDocumentName)); |
| 6505 |
|
} |
| 6506 |
|
|
| 6507 |
1 |
List<DocumentReference> childDocumentReferences = new ArrayList<DocumentReference>(); |
| 6508 |
1 |
for (String childDocumentName : childDocumentNames) { |
| 6509 |
0 |
childDocumentReferences.add(getCurrentMixedDocumentReferenceResolver().resolve(childDocumentName)); |
| 6510 |
|
} |
| 6511 |
|
|
| 6512 |
1 |
rename(getCurrentMixedDocumentReferenceResolver().resolve(newDocumentName), backlinkDocumentReferences, |
| 6513 |
|
childDocumentReferences, context); |
| 6514 |
|
} |
| 6515 |
|
|
| 6516 |
|
|
| 6517 |
|
@since |
| 6518 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
| 6519 |
126 |
public XWikiDocument copyDocument(DocumentReference newDocumentReference, XWikiContext context)... |
| 6520 |
|
throws XWikiException |
| 6521 |
|
{ |
| 6522 |
126 |
loadAttachments(context); |
| 6523 |
126 |
loadArchive(context); |
| 6524 |
|
|
| 6525 |
126 |
XWikiDocument newdoc = duplicate(newDocumentReference); |
| 6526 |
|
|
| 6527 |
|
|
| 6528 |
|
|
| 6529 |
126 |
if (StringUtils.equals(newdoc.getTitle(), getPrettyName(this.getDocumentReference()))) { |
| 6530 |
9 |
newdoc.setTitle(getPrettyName(newDocumentReference)); |
| 6531 |
|
} |
| 6532 |
|
|
| 6533 |
126 |
newdoc.setOriginalDocument(null); |
| 6534 |
126 |
newdoc.setContentDirty(true); |
| 6535 |
126 |
newdoc.getXClass().setOwnerDocument(newdoc); |
| 6536 |
|
|
| 6537 |
126 |
XWikiDocumentArchive archive = getDocumentArchive(); |
| 6538 |
126 |
if (archive != null) { |
| 6539 |
113 |
newdoc.setDocumentArchive(archive.clone(newdoc.getId(), context)); |
| 6540 |
|
} |
| 6541 |
|
|
| 6542 |
126 |
return newdoc; |
| 6543 |
|
} |
| 6544 |
|
|
| 6545 |
|
|
| 6546 |
|
|
| 6547 |
|
|
| 6548 |
|
@param |
| 6549 |
|
@return |
| 6550 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 6551 |
135 |
private String getPrettyName(DocumentReference documentReference)... |
| 6552 |
|
{ |
| 6553 |
135 |
EntityReferenceProvider defaultEntityReferenceProvider = Utils.getComponent(EntityReferenceProvider.class); |
| 6554 |
135 |
if (defaultEntityReferenceProvider.getDefaultReference(documentReference.getType()).getName() |
| 6555 |
|
.equals(documentReference.getName())) { |
| 6556 |
10 |
return documentReference.getLastSpaceReference().getName(); |
| 6557 |
|
} |
| 6558 |
125 |
return documentReference.getName(); |
| 6559 |
|
} |
| 6560 |
|
|
| 6561 |
|
|
| 6562 |
|
@deprecated@link |
| 6563 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6564 |
5 |
@Deprecated... |
| 6565 |
|
public XWikiDocument copyDocument(String newDocumentName, XWikiContext context) throws XWikiException |
| 6566 |
|
{ |
| 6567 |
5 |
return copyDocument(getCurrentMixedDocumentReferenceResolver().resolve(newDocumentName), context); |
| 6568 |
|
} |
| 6569 |
|
|
| |
|
| 72.7% |
Uncovered Elements: 3 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 6570 |
1530 |
public XWikiLock getLock(XWikiContext context) throws XWikiException... |
| 6571 |
|
{ |
| 6572 |
1530 |
XWikiLock theLock = getStore(context).loadLock(getId(), context, true); |
| 6573 |
1527 |
if (theLock != null) { |
| 6574 |
863 |
int timeout = context.getWiki().getXWikiPreferenceAsInt("lock_Timeout", 30 * 60, context); |
| 6575 |
864 |
if (theLock.getDate().getTime() + timeout * 1000 < new Date().getTime()) { |
| 6576 |
0 |
getStore(context).deleteLock(theLock, context, true); |
| 6577 |
0 |
theLock = null; |
| 6578 |
|
} |
| 6579 |
|
} |
| 6580 |
|
|
| 6581 |
1527 |
return theLock; |
| 6582 |
|
} |
| 6583 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 6584 |
552 |
public void setLock(String userName, XWikiContext context) throws XWikiException... |
| 6585 |
|
{ |
| 6586 |
555 |
XWikiLock lock = new XWikiLock(getId(), userName); |
| 6587 |
558 |
getStore(context).saveLock(lock, context, true); |
| 6588 |
|
} |
| 6589 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 6590 |
264 |
public void removeLock(XWikiContext context) throws XWikiException... |
| 6591 |
|
{ |
| 6592 |
264 |
XWikiLock lock = getStore(context).loadLock(getId(), context, true); |
| 6593 |
264 |
if (lock != null) { |
| 6594 |
263 |
getStore(context).deleteLock(lock, context, true); |
| 6595 |
|
} |
| 6596 |
|
} |
| 6597 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 6598 |
0 |
public void insertText(String text, String marker, XWikiContext context) throws XWikiException... |
| 6599 |
|
{ |
| 6600 |
0 |
setContent(StringUtils.replaceOnce(getContent(), marker, text + marker)); |
| 6601 |
0 |
context.getWiki().saveDocument(this, context); |
| 6602 |
|
} |
| 6603 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6604 |
0 |
public Object getWikiNode()... |
| 6605 |
|
{ |
| 6606 |
0 |
return this.wikiNode; |
| 6607 |
|
} |
| 6608 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6609 |
13983 |
public void setWikiNode(Object wikiNode)... |
| 6610 |
|
{ |
| 6611 |
13983 |
this.wikiNode = wikiNode; |
| 6612 |
|
} |
| 6613 |
|
|
| 6614 |
|
|
| 6615 |
|
@since |
| 6616 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6617 |
42793 |
public String getXClassXML()... |
| 6618 |
|
{ |
| 6619 |
42788 |
return this.xClassXML; |
| 6620 |
|
} |
| 6621 |
|
|
| 6622 |
|
|
| 6623 |
|
@deprecated@link |
| 6624 |
|
|
| 6625 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6626 |
7972 |
@Deprecated... |
| 6627 |
|
public String getxWikiClassXML() |
| 6628 |
|
{ |
| 6629 |
7972 |
return getXClassXML(); |
| 6630 |
|
} |
| 6631 |
|
|
| 6632 |
|
|
| 6633 |
|
@since |
| 6634 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6635 |
38638 |
public void setXClassXML(String xClassXML)... |
| 6636 |
|
{ |
| 6637 |
38642 |
this.xClassXML = xClassXML; |
| 6638 |
|
} |
| 6639 |
|
|
| 6640 |
|
|
| 6641 |
|
@deprecated@link |
| 6642 |
|
|
| 6643 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6644 |
3643 |
@Deprecated... |
| 6645 |
|
public void setxWikiClassXML(String xClassXML) |
| 6646 |
|
{ |
| 6647 |
3644 |
setXClassXML(xClassXML); |
| 6648 |
|
} |
| 6649 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6650 |
39304 |
public int getElements()... |
| 6651 |
|
{ |
| 6652 |
39303 |
return this.elements; |
| 6653 |
|
} |
| 6654 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6655 |
35135 |
public void setElements(int elements)... |
| 6656 |
|
{ |
| 6657 |
35135 |
this.elements = elements; |
| 6658 |
|
} |
| 6659 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 6660 |
7610 |
public void setElement(int element, boolean toggle)... |
| 6661 |
|
{ |
| 6662 |
7610 |
if (toggle) { |
| 6663 |
2577 |
this.elements = this.elements | element; |
| 6664 |
|
} else { |
| 6665 |
5033 |
this.elements = this.elements & (~element); |
| 6666 |
|
} |
| 6667 |
|
} |
| 6668 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6669 |
14831 |
public boolean hasElement(int element)... |
| 6670 |
|
{ |
| 6671 |
14834 |
return ((this.elements & element) == element); |
| 6672 |
|
} |
| 6673 |
|
|
| 6674 |
|
|
| 6675 |
|
|
| 6676 |
|
|
| 6677 |
|
|
| 6678 |
|
|
| 6679 |
|
|
| 6680 |
|
|
| 6681 |
|
@return |
| 6682 |
|
@param |
| 6683 |
|
@throws |
| 6684 |
|
|
| 6685 |
|
|
| |
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 6686 |
26740 |
public String getDefaultEditMode(XWikiContext context) throws XWikiException... |
| 6687 |
|
{ |
| 6688 |
26741 |
try { |
| 6689 |
26733 |
return getDefaultEditModeInternal(context); |
| 6690 |
|
} catch (Exception e) { |
| 6691 |
|
|
| 6692 |
|
|
| 6693 |
0 |
LOGGER.error("Failed to get the default edit mode for [{}]", getDocumentReference(), e); |
| 6694 |
0 |
return "edit"; |
| 6695 |
|
} |
| 6696 |
|
} |
| 6697 |
|
|
| |
|
| 73.5% |
Uncovered Elements: 13 (49) |
Complexity: 11 |
Complexity Density: 0.38 |
|
| 6698 |
26734 |
private String getDefaultEditModeInternal(XWikiContext context) throws XWikiException... |
| 6699 |
|
{ |
| 6700 |
26736 |
String editModeProperty = "defaultEditMode"; |
| 6701 |
26738 |
DocumentReference editModeClass = |
| 6702 |
|
getCurrentReferenceDocumentReferenceResolver().resolve(XWikiConstant.EDIT_MODE_CLASS); |
| 6703 |
|
|
| 6704 |
26742 |
BaseObject editModeObject = this.getXObject(editModeClass); |
| 6705 |
26735 |
if (editModeObject != null) { |
| 6706 |
0 |
String defaultEditMode = editModeObject.getStringValue(editModeProperty); |
| 6707 |
0 |
if (StringUtils.isEmpty(defaultEditMode)) { |
| 6708 |
0 |
return "edit"; |
| 6709 |
|
} else { |
| 6710 |
0 |
return defaultEditMode; |
| 6711 |
|
} |
| 6712 |
|
} |
| 6713 |
|
|
| 6714 |
26737 |
com.xpn.xwiki.XWiki xwiki = context.getWiki(); |
| 6715 |
26737 |
if (is10Syntax()) { |
| 6716 |
10 |
if (getContent().indexOf("includeForm(") != -1) { |
| 6717 |
2 |
return "inline"; |
| 6718 |
|
} |
| 6719 |
|
} else { |
| 6720 |
|
|
| 6721 |
|
|
| 6722 |
|
|
| 6723 |
|
|
| 6724 |
|
|
| 6725 |
|
|
| 6726 |
|
|
| 6727 |
26726 |
for (Block macroBlock : getXDOM().getBlocks(new MacroBlockMatcher("include"), Axes.CHILD)) { |
| 6728 |
|
|
| 6729 |
|
|
| 6730 |
|
|
| 6731 |
|
|
| 6732 |
1160 |
String includedDocumentReference = macroBlock.getParameter("reference"); |
| 6733 |
1160 |
if (includedDocumentReference == null) { |
| 6734 |
0 |
includedDocumentReference = macroBlock.getParameter("document"); |
| 6735 |
|
} |
| 6736 |
1160 |
if (includedDocumentReference != null) { |
| 6737 |
|
|
| 6738 |
1160 |
DocumentReference documentReference = |
| 6739 |
|
getCurrentMixedDocumentReferenceResolver().resolve(includedDocumentReference); |
| 6740 |
1160 |
XWikiDocument includedDocument = xwiki.getDocument(documentReference, context); |
| 6741 |
1160 |
if (!includedDocument.isNew()) { |
| 6742 |
|
|
| 6743 |
|
|
| 6744 |
1108 |
editModeObject = includedDocument.getXObject(editModeClass); |
| 6745 |
1108 |
if (editModeObject == null) { |
| 6746 |
1108 |
editModeObject = includedDocument.getXObject(SHEETCLASS_REFERENCE); |
| 6747 |
|
} |
| 6748 |
1108 |
if (editModeObject != null) { |
| 6749 |
|
|
| 6750 |
2 |
String defaultEditMode = editModeObject.getStringValue(editModeProperty); |
| 6751 |
2 |
if (StringUtils.isBlank(defaultEditMode)) { |
| 6752 |
|
|
| 6753 |
|
|
| 6754 |
2 |
return "inline"; |
| 6755 |
|
} else { |
| 6756 |
0 |
return defaultEditMode; |
| 6757 |
|
} |
| 6758 |
|
} |
| 6759 |
|
} |
| 6760 |
|
} |
| 6761 |
|
} |
| 6762 |
|
} |
| 6763 |
|
|
| 6764 |
26737 |
return "edit"; |
| 6765 |
|
} |
| 6766 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 6767 |
0 |
public String getDefaultEditURL(XWikiContext context) throws XWikiException... |
| 6768 |
|
{ |
| 6769 |
0 |
String editMode = getDefaultEditMode(context); |
| 6770 |
|
|
| 6771 |
0 |
if ("inline".equals(editMode)) { |
| 6772 |
0 |
return getEditURL("inline", "", context); |
| 6773 |
|
} else { |
| 6774 |
0 |
com.xpn.xwiki.XWiki xwiki = context.getWiki(); |
| 6775 |
0 |
String editor = xwiki.getEditorPreference(context); |
| 6776 |
0 |
return getEditURL("edit", editor, context); |
| 6777 |
|
} |
| 6778 |
|
} |
| 6779 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 6780 |
0 |
public String getEditURL(String action, String mode, XWikiContext context) throws XWikiException... |
| 6781 |
|
{ |
| 6782 |
0 |
com.xpn.xwiki.XWiki xwiki = context.getWiki(); |
| 6783 |
0 |
String language = ""; |
| 6784 |
0 |
XWikiDocument tdoc = (XWikiDocument) context.get("tdoc"); |
| 6785 |
0 |
String realLang = tdoc.getRealLanguage(context); |
| 6786 |
0 |
if ((xwiki.isMultiLingual(context) == true) && (!realLang.equals(""))) { |
| 6787 |
0 |
language = realLang; |
| 6788 |
|
} |
| 6789 |
|
|
| 6790 |
0 |
return getEditURL(action, mode, language, context); |
| 6791 |
|
} |
| 6792 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 6793 |
0 |
public String getEditURL(String action, String mode, String language, XWikiContext context)... |
| 6794 |
|
{ |
| 6795 |
0 |
StringBuilder editparams = new StringBuilder(); |
| 6796 |
0 |
if (!mode.equals("")) { |
| 6797 |
0 |
editparams.append("xpage="); |
| 6798 |
0 |
editparams.append(mode); |
| 6799 |
|
} |
| 6800 |
|
|
| 6801 |
0 |
if (!language.equals("")) { |
| 6802 |
0 |
if (!mode.equals("")) { |
| 6803 |
0 |
editparams.append("&"); |
| 6804 |
|
} |
| 6805 |
0 |
editparams.append("language="); |
| 6806 |
0 |
editparams.append(language); |
| 6807 |
|
} |
| 6808 |
|
|
| 6809 |
0 |
return getURL(action, editparams.toString(), context); |
| 6810 |
|
} |
| 6811 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 6812 |
46625 |
public String getDefaultTemplate()... |
| 6813 |
|
{ |
| 6814 |
46622 |
if (this.defaultTemplate == null) { |
| 6815 |
16517 |
return ""; |
| 6816 |
|
} else { |
| 6817 |
30102 |
return this.defaultTemplate; |
| 6818 |
|
} |
| 6819 |
|
} |
| 6820 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 6821 |
42638 |
public void setDefaultTemplate(String defaultTemplate)... |
| 6822 |
|
{ |
| 6823 |
42638 |
this.defaultTemplate = defaultTemplate; |
| 6824 |
|
|
| 6825 |
42635 |
setMetaDataDirty(true); |
| 6826 |
|
} |
| 6827 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6828 |
0 |
public Vector<BaseObject> getComments()... |
| 6829 |
|
{ |
| 6830 |
0 |
return getComments(true); |
| 6831 |
|
} |
| 6832 |
|
|
| 6833 |
|
|
| 6834 |
|
@return |
| 6835 |
|
@since |
| 6836 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 6837 |
141212 |
@Override... |
| 6838 |
|
public Syntax getSyntax() |
| 6839 |
|
{ |
| 6840 |
|
|
| 6841 |
|
|
| 6842 |
141224 |
if (isNew() && this.syntax == null) { |
| 6843 |
17044 |
this.syntax = getDefaultDocumentSyntax(); |
| 6844 |
|
} |
| 6845 |
|
|
| 6846 |
141219 |
return this.syntax; |
| 6847 |
|
} |
| 6848 |
|
|
| 6849 |
|
|
| 6850 |
|
@inheritDoc |
| 6851 |
|
|
| 6852 |
|
|
| 6853 |
|
|
| 6854 |
|
|
| 6855 |
|
@see |
| 6856 |
|
@deprecated |
| 6857 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6858 |
48031 |
@Override... |
| 6859 |
|
@Deprecated |
| 6860 |
|
public String getSyntaxId() |
| 6861 |
|
{ |
| 6862 |
48029 |
return getSyntax().toIdString(); |
| 6863 |
|
} |
| 6864 |
|
|
| 6865 |
|
|
| 6866 |
|
@param |
| 6867 |
|
@see |
| 6868 |
|
@since |
| 6869 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 6870 |
44831 |
public void setSyntax(Syntax syntax)... |
| 6871 |
|
{ |
| 6872 |
44836 |
if (ObjectUtils.notEqual(this.syntax, syntax)) { |
| 6873 |
39610 |
this.syntax = syntax; |
| 6874 |
|
|
| 6875 |
39608 |
this.xdomCache = null; |
| 6876 |
|
} |
| 6877 |
|
} |
| 6878 |
|
|
| 6879 |
|
|
| 6880 |
|
|
| 6881 |
|
|
| 6882 |
|
@param |
| 6883 |
|
@see |
| 6884 |
|
@deprecated |
| 6885 |
|
|
| |
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 6886 |
3648 |
@Deprecated... |
| 6887 |
|
public void setSyntaxId(String syntaxId) |
| 6888 |
|
{ |
| 6889 |
3648 |
Syntax syntax; |
| 6890 |
|
|
| 6891 |
|
|
| 6892 |
|
|
| 6893 |
|
|
| 6894 |
|
|
| 6895 |
3644 |
if (StringUtils.isBlank(syntaxId)) { |
| 6896 |
0 |
syntax = Syntax.XWIKI_1_0; |
| 6897 |
|
} else { |
| 6898 |
3644 |
try { |
| 6899 |
3645 |
syntax = getSyntaxFactory().createSyntaxFromIdString(syntaxId); |
| 6900 |
|
} catch (ParseException e) { |
| 6901 |
0 |
syntax = getDefaultDocumentSyntax(); |
| 6902 |
0 |
LOGGER.warn("Failed to set syntax [" + syntaxId + "] for [" |
| 6903 |
|
+ getDefaultEntityReferenceSerializer().serialize(getDocumentReference()) + "], setting syntax [" |
| 6904 |
|
+ syntax.toIdString() + "] instead.", e); |
| 6905 |
|
} |
| 6906 |
|
} |
| 6907 |
|
|
| 6908 |
3647 |
setSyntax(syntax); |
| 6909 |
|
} |
| 6910 |
|
|
| |
|
| 53.3% |
Uncovered Elements: 7 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 6911 |
850 |
public Vector<BaseObject> getComments(boolean asc)... |
| 6912 |
|
{ |
| 6913 |
850 |
List<BaseObject> list = getXObjects(COMMENTSCLASS_REFERENCE); |
| 6914 |
850 |
if (list == null) { |
| 6915 |
835 |
return null; |
| 6916 |
15 |
} else if (asc) { |
| 6917 |
15 |
return new Vector<BaseObject>(list); |
| 6918 |
|
} else { |
| 6919 |
0 |
Vector<BaseObject> newlist = new Vector<BaseObject>(); |
| 6920 |
0 |
for (int i = list.size() - 1; i >= 0; i--) { |
| 6921 |
0 |
newlist.add(list.get(i)); |
| 6922 |
|
} |
| 6923 |
0 |
return newlist; |
| 6924 |
|
} |
| 6925 |
|
} |
| 6926 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 6927 |
0 |
public boolean isCurrentUserCreator(XWikiContext context)... |
| 6928 |
|
{ |
| 6929 |
0 |
return isCreator(context.getUserReference()); |
| 6930 |
|
} |
| 6931 |
|
|
| 6932 |
|
|
| 6933 |
|
@deprecated@link |
| 6934 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 6935 |
0 |
@Deprecated... |
| 6936 |
|
public boolean isCreator(String username) |
| 6937 |
|
{ |
| 6938 |
0 |
if (username.equals(XWikiRightService.GUEST_USER_FULLNAME)) { |
| 6939 |
0 |
return false; |
| 6940 |
|
} |
| 6941 |
|
|
| 6942 |
0 |
return username.equals(getCreator()); |
| 6943 |
|
} |
| 6944 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 6945 |
0 |
public boolean isCreator(DocumentReference username)... |
| 6946 |
|
{ |
| 6947 |
0 |
if (username == null) { |
| 6948 |
0 |
return false; |
| 6949 |
|
} |
| 6950 |
|
|
| 6951 |
0 |
return username.equals(getCreatorReference()); |
| 6952 |
|
} |
| 6953 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 6954 |
11 |
public boolean isCurrentUserPage(XWikiContext context)... |
| 6955 |
|
{ |
| 6956 |
11 |
DocumentReference userReference = context.getUserReference(); |
| 6957 |
11 |
if (userReference == null) { |
| 6958 |
0 |
return false; |
| 6959 |
|
} |
| 6960 |
|
|
| 6961 |
11 |
return userReference.equals(getDocumentReference()); |
| 6962 |
|
} |
| 6963 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 6964 |
0 |
public boolean isCurrentLocalUserPage(XWikiContext context)... |
| 6965 |
|
{ |
| 6966 |
0 |
final DocumentReference userRef = context.getUserReference(); |
| 6967 |
0 |
return userRef != null && userRef.equals(this.getDocumentReference()); |
| 6968 |
|
} |
| 6969 |
|
|
| |
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 6970 |
1978 |
public void resetArchive(XWikiContext context) throws XWikiException... |
| 6971 |
|
{ |
| 6972 |
1978 |
boolean hasVersioning = context.getWiki().hasVersioning(context); |
| 6973 |
1978 |
if (hasVersioning) { |
| 6974 |
1978 |
getVersioningStore(context).resetRCSArchive(this, true, context); |
| 6975 |
|
} |
| 6976 |
|
} |
| 6977 |
|
|
| 6978 |
|
|
| 6979 |
|
|
| 6980 |
|
|
| 6981 |
|
@since |
| 6982 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 6983 |
0 |
public BaseObject addXObjectFromRequest(XWikiContext context) throws XWikiException... |
| 6984 |
|
{ |
| 6985 |
|
|
| 6986 |
0 |
ObjectAddForm form = new ObjectAddForm(); |
| 6987 |
0 |
form.setRequest(context.getRequest()); |
| 6988 |
0 |
form.readRequest(); |
| 6989 |
|
|
| 6990 |
0 |
EntityReference classReference = getXClassEntityReferenceResolver().resolve(form.getClassName(), |
| 6991 |
|
EntityType.DOCUMENT, getDocumentReference()); |
| 6992 |
0 |
BaseObject object = newXObject(classReference, context); |
| 6993 |
0 |
BaseClass baseclass = object.getXClass(context); |
| 6994 |
0 |
baseclass.fromMap(form.getObject(LOCAL_REFERENCE_SERIALIZER.serialize(resolveClassReference(classReference))), |
| 6995 |
|
object); |
| 6996 |
|
|
| 6997 |
0 |
return object; |
| 6998 |
|
} |
| 6999 |
|
|
| 7000 |
|
|
| 7001 |
|
|
| 7002 |
|
|
| 7003 |
|
@since |
| 7004 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7005 |
0 |
public BaseObject addXObjectFromRequest(EntityReference classReference, XWikiContext context) throws XWikiException... |
| 7006 |
|
{ |
| 7007 |
0 |
return addXObjectFromRequest(classReference, "", 0, context); |
| 7008 |
|
} |
| 7009 |
|
|
| 7010 |
|
|
| 7011 |
|
@deprecated@link |
| 7012 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7013 |
0 |
@Deprecated... |
| 7014 |
|
public BaseObject addObjectFromRequest(String className, XWikiContext context) throws XWikiException |
| 7015 |
|
{ |
| 7016 |
0 |
return addObjectFromRequest(className, "", 0, context); |
| 7017 |
|
} |
| 7018 |
|
|
| 7019 |
|
|
| 7020 |
|
|
| 7021 |
|
|
| 7022 |
|
@since |
| 7023 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7024 |
0 |
public BaseObject addXObjectFromRequest(DocumentReference classReference, String prefix, XWikiContext context)... |
| 7025 |
|
throws XWikiException |
| 7026 |
|
{ |
| 7027 |
0 |
return addXObjectFromRequest(classReference, prefix, 0, context); |
| 7028 |
|
} |
| 7029 |
|
|
| 7030 |
|
|
| 7031 |
|
@deprecated@link |
| 7032 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7033 |
0 |
@Deprecated... |
| 7034 |
|
public BaseObject addObjectFromRequest(String className, String prefix, XWikiContext context) throws XWikiException |
| 7035 |
|
{ |
| 7036 |
0 |
return addObjectFromRequest(className, prefix, 0, context); |
| 7037 |
|
} |
| 7038 |
|
|
| 7039 |
|
|
| 7040 |
|
|
| 7041 |
|
|
| 7042 |
|
@since |
| 7043 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7044 |
0 |
public List<BaseObject> addXObjectsFromRequest(DocumentReference classReference, XWikiContext context)... |
| 7045 |
|
throws XWikiException |
| 7046 |
|
{ |
| 7047 |
0 |
return addXObjectsFromRequest(classReference, "", context); |
| 7048 |
|
} |
| 7049 |
|
|
| 7050 |
|
|
| 7051 |
|
@deprecated@link |
| 7052 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7053 |
0 |
@Deprecated... |
| 7054 |
|
public List<BaseObject> addObjectsFromRequest(String className, XWikiContext context) throws XWikiException |
| 7055 |
|
{ |
| 7056 |
0 |
return addObjectsFromRequest(className, "", context); |
| 7057 |
|
} |
| 7058 |
|
|
| 7059 |
|
|
| 7060 |
|
|
| 7061 |
|
|
| 7062 |
|
@since |
| 7063 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 3 |
Complexity Density: 0.23 |
|
| 7064 |
0 |
public List<BaseObject> addXObjectsFromRequest(DocumentReference classReference, String pref, XWikiContext context)... |
| 7065 |
|
throws XWikiException |
| 7066 |
|
{ |
| 7067 |
0 |
@SuppressWarnings("unchecked") |
| 7068 |
|
Map<String, String[]> map = context.getRequest().getParameterMap(); |
| 7069 |
0 |
List<Integer> objectsNumberDone = new ArrayList<Integer>(); |
| 7070 |
0 |
List<BaseObject> objects = new ArrayList<BaseObject>(); |
| 7071 |
0 |
String start = pref + LOCAL_REFERENCE_SERIALIZER.serialize(classReference) + "_"; |
| 7072 |
|
|
| 7073 |
0 |
for (String name : map.keySet()) { |
| 7074 |
0 |
if (name.startsWith(start)) { |
| 7075 |
0 |
int pos = name.indexOf('_', start.length() + 1); |
| 7076 |
0 |
String prefix = name.substring(0, pos); |
| 7077 |
0 |
int num = Integer.decode(prefix.substring(prefix.lastIndexOf('_') + 1)).intValue(); |
| 7078 |
0 |
if (!objectsNumberDone.contains(Integer.valueOf(num))) { |
| 7079 |
0 |
objectsNumberDone.add(Integer.valueOf(num)); |
| 7080 |
0 |
objects.add(addXObjectFromRequest(classReference, pref, num, context)); |
| 7081 |
|
} |
| 7082 |
|
} |
| 7083 |
|
} |
| 7084 |
|
|
| 7085 |
0 |
return objects; |
| 7086 |
|
} |
| 7087 |
|
|
| 7088 |
|
|
| 7089 |
|
@deprecated@link |
| 7090 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7091 |
0 |
@Deprecated... |
| 7092 |
|
public List<BaseObject> addObjectsFromRequest(String className, String pref, XWikiContext context) |
| 7093 |
|
throws XWikiException |
| 7094 |
|
{ |
| 7095 |
0 |
return addXObjectsFromRequest(resolveClassReference(className), pref, context); |
| 7096 |
|
} |
| 7097 |
|
|
| 7098 |
|
|
| 7099 |
|
|
| 7100 |
|
|
| 7101 |
|
@since |
| 7102 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7103 |
0 |
public BaseObject addXObjectFromRequest(DocumentReference classReference, int num, XWikiContext context)... |
| 7104 |
|
throws XWikiException |
| 7105 |
|
{ |
| 7106 |
0 |
return addXObjectFromRequest(classReference, "", num, context); |
| 7107 |
|
} |
| 7108 |
|
|
| 7109 |
|
|
| 7110 |
|
@deprecated@link |
| 7111 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7112 |
0 |
@Deprecated... |
| 7113 |
|
public BaseObject addObjectFromRequest(String className, int num, XWikiContext context) throws XWikiException |
| 7114 |
|
{ |
| 7115 |
0 |
return addObjectFromRequest(className, "", num, context); |
| 7116 |
|
} |
| 7117 |
|
|
| 7118 |
|
|
| 7119 |
|
|
| 7120 |
|
|
| 7121 |
|
@since |
| 7122 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 7123 |
0 |
public BaseObject addXObjectFromRequest(EntityReference classReference, String prefix, int num,... |
| 7124 |
|
XWikiContext context) throws XWikiException |
| 7125 |
|
{ |
| 7126 |
0 |
BaseObject object = newXObject(classReference, context); |
| 7127 |
0 |
BaseClass baseclass = object.getXClass(context); |
| 7128 |
0 |
String newPrefix = |
| 7129 |
|
prefix + LOCAL_REFERENCE_SERIALIZER.serialize(resolveClassReference(classReference)) + "_" + num; |
| 7130 |
0 |
baseclass.fromMap(Util.getObject(context.getRequest(), newPrefix), object); |
| 7131 |
|
|
| 7132 |
0 |
return object; |
| 7133 |
|
} |
| 7134 |
|
|
| 7135 |
|
|
| 7136 |
|
@deprecated@link |
| 7137 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7138 |
0 |
@Deprecated... |
| 7139 |
|
public BaseObject addObjectFromRequest(String className, String prefix, int num, XWikiContext context) |
| 7140 |
|
throws XWikiException |
| 7141 |
|
{ |
| 7142 |
0 |
return addXObjectFromRequest(resolveClassReference(className), prefix, num, context); |
| 7143 |
|
} |
| 7144 |
|
|
| 7145 |
|
|
| 7146 |
|
|
| 7147 |
|
|
| 7148 |
|
@since |
| 7149 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7150 |
0 |
public BaseObject updateXObjectFromRequest(EntityReference classReference, XWikiContext context)... |
| 7151 |
|
throws XWikiException |
| 7152 |
|
{ |
| 7153 |
0 |
return updateXObjectFromRequest(classReference, "", context); |
| 7154 |
|
} |
| 7155 |
|
|
| 7156 |
|
|
| 7157 |
|
@deprecated@link |
| 7158 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7159 |
0 |
@Deprecated... |
| 7160 |
|
public BaseObject updateObjectFromRequest(String className, XWikiContext context) throws XWikiException |
| 7161 |
|
{ |
| 7162 |
0 |
return updateObjectFromRequest(className, "", context); |
| 7163 |
|
} |
| 7164 |
|
|
| 7165 |
|
|
| 7166 |
|
|
| 7167 |
|
|
| 7168 |
|
@since |
| 7169 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7170 |
0 |
public BaseObject updateXObjectFromRequest(EntityReference classReference, String prefix, XWikiContext context)... |
| 7171 |
|
throws XWikiException |
| 7172 |
|
{ |
| 7173 |
0 |
return updateXObjectFromRequest(classReference, prefix, 0, context); |
| 7174 |
|
} |
| 7175 |
|
|
| 7176 |
|
|
| 7177 |
|
@deprecated@link |
| 7178 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 7179 |
0 |
@Deprecated... |
| 7180 |
|
public BaseObject updateObjectFromRequest(String className, String prefix, XWikiContext context) |
| 7181 |
|
throws XWikiException |
|