| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package com.xpn.xwiki.plugin.webdav.resources.partial; |
| 21 |
|
|
| 22 |
|
import java.util.ArrayList; |
| 23 |
|
import java.util.Date; |
| 24 |
|
import java.util.List; |
| 25 |
|
import java.util.Map; |
| 26 |
|
|
| 27 |
|
import org.apache.jackrabbit.webdav.DavConstants; |
| 28 |
|
import org.apache.jackrabbit.webdav.DavException; |
| 29 |
|
import org.apache.jackrabbit.webdav.DavMethods; |
| 30 |
|
import org.apache.jackrabbit.webdav.DavResource; |
| 31 |
|
import org.apache.jackrabbit.webdav.DavResourceFactory; |
| 32 |
|
import org.apache.jackrabbit.webdav.DavResourceLocator; |
| 33 |
|
import org.apache.jackrabbit.webdav.DavServletResponse; |
| 34 |
|
import org.apache.jackrabbit.webdav.DavSession; |
| 35 |
|
import org.apache.jackrabbit.webdav.MultiStatusResponse; |
| 36 |
|
import org.apache.jackrabbit.webdav.io.InputContext; |
| 37 |
|
import org.apache.jackrabbit.webdav.lock.ActiveLock; |
| 38 |
|
import org.apache.jackrabbit.webdav.lock.LockDiscovery; |
| 39 |
|
import org.apache.jackrabbit.webdav.lock.LockInfo; |
| 40 |
|
import org.apache.jackrabbit.webdav.lock.LockManager; |
| 41 |
|
import org.apache.jackrabbit.webdav.lock.Scope; |
| 42 |
|
import org.apache.jackrabbit.webdav.lock.SupportedLock; |
| 43 |
|
import org.apache.jackrabbit.webdav.lock.Type; |
| 44 |
|
import org.apache.jackrabbit.webdav.property.DavProperty; |
| 45 |
|
import org.apache.jackrabbit.webdav.property.DavPropertyName; |
| 46 |
|
import org.apache.jackrabbit.webdav.property.DavPropertyNameIterator; |
| 47 |
|
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet; |
| 48 |
|
import org.apache.jackrabbit.webdav.property.DavPropertySet; |
| 49 |
|
import org.apache.jackrabbit.webdav.property.DefaultDavProperty; |
| 50 |
|
import org.apache.jackrabbit.webdav.property.ResourceType; |
| 51 |
|
|
| 52 |
|
import com.xpn.xwiki.plugin.webdav.resources.XWikiDavResource; |
| 53 |
|
import com.xpn.xwiki.plugin.webdav.resources.domain.DavTempFile; |
| 54 |
|
import com.xpn.xwiki.plugin.webdav.utils.XWikiDavContext; |
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
@version |
| 60 |
|
|
| |
|
| 56.7% |
Uncovered Elements: 87 (201) |
Complexity: 61 |
Complexity Density: 0.5 |
|
| 61 |
|
public abstract class AbstractDavResource implements XWikiDavResource |
| 62 |
|
{ |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
protected String name; |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
@link |
| 70 |
|
|
| 71 |
|
protected DavResourceLocator locator; |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
protected XWikiDavResource parentResource; |
| 77 |
|
|
| 78 |
|
|
| 79 |
|
@link |
| 80 |
|
|
| 81 |
|
private XWikiDavContext context; |
| 82 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 83 |
180 |
@Override... |
| 84 |
|
public void init(XWikiDavResource parent, String name, String relativePath) throws DavException |
| 85 |
|
{ |
| 86 |
180 |
DavResourceLocator locator = |
| 87 |
|
parent.getLocator().getFactory().createResourceLocator(parent.getLocator().getPrefix(), |
| 88 |
|
parent.getLocator().getWorkspacePath(), parent.getLocator().getResourcePath() + relativePath); |
| 89 |
180 |
init(name, locator, parent.getContext()); |
| 90 |
180 |
this.parentResource = parent; |
| 91 |
|
|
| 92 |
|
} |
| 93 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 3 |
Complexity Density: 0.18 |
|
| 94 |
264 |
@Override... |
| 95 |
|
public void init(String name, DavResourceLocator locator, XWikiDavContext context) throws DavException |
| 96 |
|
{ |
| 97 |
264 |
this.name = name; |
| 98 |
264 |
this.locator = locator; |
| 99 |
264 |
this.context = context; |
| 100 |
|
|
| 101 |
|
|
| 102 |
264 |
DavPropertySet propertySet = getVirtualProperties(); |
| 103 |
264 |
if (propertySet.get(DavPropertyName.CREATIONDATE) == null) { |
| 104 |
37 |
String timeStamp = DavConstants.creationDateFormat.format(new Date()); |
| 105 |
37 |
propertySet.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, timeStamp)); |
| 106 |
|
} |
| 107 |
264 |
propertySet.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME, getDisplayName())); |
| 108 |
264 |
if (isCollection()) { |
| 109 |
212 |
propertySet.add(new ResourceType(ResourceType.COLLECTION)); |
| 110 |
|
|
| 111 |
212 |
propertySet.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "1")); |
| 112 |
|
} else { |
| 113 |
52 |
propertySet.add(new ResourceType(ResourceType.DEFAULT_RESOURCE)); |
| 114 |
|
|
| 115 |
52 |
propertySet.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "0")); |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
264 |
propertySet.add(new LockDiscovery(getLock(Type.WRITE, Scope.EXCLUSIVE))); |
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
264 |
SupportedLock supportedLock = new SupportedLock(); |
| 126 |
264 |
supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE); |
| 127 |
264 |
propertySet.add(supportedLock); |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 2 (22) |
Complexity: 6 |
Complexity Density: 0.43 |
|
| 134 |
36 |
public XWikiDavResource decode(String[] tokens, int next) throws DavException... |
| 135 |
|
{ |
| 136 |
36 |
if (!isCollection()) { |
| 137 |
0 |
throw new DavException(DavServletResponse.SC_BAD_REQUEST); |
| 138 |
|
} |
| 139 |
36 |
String nextToken = tokens[next]; |
| 140 |
36 |
boolean last = (next == tokens.length - 1); |
| 141 |
36 |
DavTempFile resource = new DavTempFile(); |
| 142 |
36 |
String method = getContext().getMethod(); |
| 143 |
36 |
if (method != null && DavMethods.getMethodCode(method) == DavMethods.DAV_MKCOL) { |
| 144 |
5 |
resource.setCollection(); |
| 145 |
|
} |
| 146 |
36 |
resource.init(this, nextToken, "/" + nextToken); |
| 147 |
|
|
| 148 |
36 |
int index = getVirtualMembers().indexOf(resource); |
| 149 |
36 |
if (index != -1) { |
| 150 |
|
|
| 151 |
26 |
resource = (DavTempFile) getVirtualMembers().get(index); |
| 152 |
|
|
| 153 |
26 |
resource.init(this, nextToken, "/" + nextToken); |
| 154 |
|
} |
| 155 |
36 |
return last ? resource : resource.decode(tokens, next + 1); |
| 156 |
|
} |
| 157 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 158 |
0 |
@Override... |
| 159 |
|
public boolean isLockable(Type type, Scope scope) |
| 160 |
|
{ |
| 161 |
0 |
return Type.WRITE.equals(type) && Scope.EXCLUSIVE.equals(scope); |
| 162 |
|
} |
| 163 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 164 |
264 |
@Override... |
| 165 |
|
public ActiveLock getLock(Type type, Scope scope) |
| 166 |
|
{ |
| 167 |
264 |
return getContext().getLockManager().getLock(type, scope, this); |
| 168 |
|
} |
| 169 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 170 |
0 |
@Override... |
| 171 |
|
public ActiveLock[] getLocks() |
| 172 |
|
{ |
| 173 |
0 |
ActiveLock writeLock = getLock(Type.WRITE, Scope.EXCLUSIVE); |
| 174 |
0 |
return (writeLock != null) ? new ActiveLock[] {writeLock} : new ActiveLock[0]; |
| 175 |
|
} |
| 176 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 177 |
0 |
@Override... |
| 178 |
|
public boolean hasLock(Type type, Scope scope) |
| 179 |
|
{ |
| 180 |
0 |
return getLock(type, scope) != null; |
| 181 |
|
} |
| 182 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 183 |
0 |
@Override... |
| 184 |
|
public ActiveLock lock(LockInfo reqLockInfo) throws DavException |
| 185 |
|
{ |
| 186 |
0 |
ActiveLock lock = null; |
| 187 |
0 |
if (isLockable(reqLockInfo.getType(), reqLockInfo.getScope())) { |
| 188 |
0 |
lock = getContext().getLockManager().createLock(reqLockInfo, this); |
| 189 |
|
} else { |
| 190 |
0 |
throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED); |
| 191 |
|
} |
| 192 |
0 |
return lock; |
| 193 |
|
} |
| 194 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 195 |
0 |
@Override... |
| 196 |
|
public ActiveLock refreshLock(LockInfo reqLockInfo, String lockToken) throws DavException |
| 197 |
|
{ |
| 198 |
0 |
if (!exists()) { |
| 199 |
0 |
throw new DavException(DavServletResponse.SC_NOT_FOUND); |
| 200 |
|
} |
| 201 |
0 |
ActiveLock lock = getLock(reqLockInfo.getType(), reqLockInfo.getScope()); |
| 202 |
0 |
if (lock == null) { |
| 203 |
0 |
throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED); |
| 204 |
|
} |
| 205 |
0 |
return getContext().getLockManager().refreshLock(reqLockInfo, lockToken, this); |
| 206 |
|
} |
| 207 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 208 |
0 |
@Override... |
| 209 |
|
public void unlock(String lockToken) throws DavException |
| 210 |
|
{ |
| 211 |
0 |
ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE); |
| 212 |
0 |
if (lock != null && lock.isLockedByToken(lockToken)) { |
| 213 |
0 |
getContext().getLockManager().releaseLock(lockToken, this); |
| 214 |
|
} |
| 215 |
|
} |
| 216 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 217 |
0 |
@Override... |
| 218 |
|
public void copy(DavResource destination, boolean shallow) throws DavException |
| 219 |
|
{ |
| 220 |
0 |
throw new DavException(DavServletResponse.SC_NOT_IMPLEMENTED); |
| 221 |
|
} |
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
| 225 |
|
|
| 226 |
|
@return |
| 227 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 228 |
592 |
public DavPropertySet getProperties()... |
| 229 |
|
{ |
| 230 |
592 |
return getVirtualProperties(); |
| 231 |
|
} |
| 232 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 233 |
0 |
@Override... |
| 234 |
|
public DavProperty getProperty(DavPropertyName name) |
| 235 |
|
{ |
| 236 |
0 |
return getProperties().get(name); |
| 237 |
|
} |
| 238 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 239 |
0 |
@Override... |
| 240 |
|
public DavPropertyName[] getPropertyNames() |
| 241 |
|
{ |
| 242 |
0 |
return getProperties().getPropertyNames(); |
| 243 |
|
} |
| 244 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 245 |
0 |
@Override... |
| 246 |
|
public MultiStatusResponse alterProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) |
| 247 |
|
throws DavException |
| 248 |
|
{ |
| 249 |
0 |
getProperties().addAll(setProperties); |
| 250 |
0 |
DavPropertyNameIterator it = removePropertyNames.iterator(); |
| 251 |
0 |
while (it.hasNext()) { |
| 252 |
0 |
removeProperty(it.nextPropertyName()); |
| 253 |
|
} |
| 254 |
0 |
return createPropStat(); |
| 255 |
|
} |
| 256 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 257 |
0 |
@SuppressWarnings("unchecked")... |
| 258 |
|
@Override |
| 259 |
|
public MultiStatusResponse alterProperties(List changeList) throws DavException |
| 260 |
|
{ |
| 261 |
0 |
for (Object next : changeList) { |
| 262 |
0 |
if (next instanceof DavProperty) { |
| 263 |
0 |
DavProperty property = (DavProperty) next; |
| 264 |
0 |
setProperty(property); |
| 265 |
|
} else { |
| 266 |
0 |
DavPropertyName propertyName = (DavPropertyName) next; |
| 267 |
0 |
removeProperty(propertyName); |
| 268 |
|
} |
| 269 |
|
} |
| 270 |
0 |
return createPropStat(); |
| 271 |
|
} |
| 272 |
|
|
| 273 |
|
|
| 274 |
|
@return@link |
| 275 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 276 |
0 |
private MultiStatusResponse createPropStat()... |
| 277 |
|
{ |
| 278 |
0 |
DavPropertyNameSet propertyNameSet = new DavPropertyNameSet(); |
| 279 |
0 |
for (DavPropertyName propertyName : getPropertyNames()) { |
| 280 |
0 |
propertyNameSet.add(propertyName); |
| 281 |
|
} |
| 282 |
0 |
return new MultiStatusResponse(this, propertyNameSet); |
| 283 |
|
} |
| 284 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 285 |
0 |
@Override... |
| 286 |
|
public void removeProperty(DavPropertyName propertyName) throws DavException |
| 287 |
|
{ |
| 288 |
0 |
getProperties().remove(propertyName); |
| 289 |
|
} |
| 290 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 291 |
0 |
@Override... |
| 292 |
|
public void setProperty(DavProperty property) throws DavException |
| 293 |
|
{ |
| 294 |
0 |
getProperties().add(property); |
| 295 |
|
} |
| 296 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 297 |
0 |
@Override... |
| 298 |
|
public void addLockManager(LockManager lockmgr) |
| 299 |
|
{ |
| 300 |
0 |
throw new UnsupportedOperationException(); |
| 301 |
|
} |
| 302 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 303 |
368 |
@Override... |
| 304 |
|
public String getDisplayName() |
| 305 |
|
{ |
| 306 |
368 |
return this.name; |
| 307 |
|
} |
| 308 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 309 |
0 |
@Override... |
| 310 |
|
public String getComplianceClass() |
| 311 |
|
{ |
| 312 |
0 |
return COMPLIANCE_CLASS; |
| 313 |
|
} |
| 314 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 315 |
0 |
@Override... |
| 316 |
|
public String getSupportedMethods() |
| 317 |
|
{ |
| 318 |
0 |
return METHODS; |
| 319 |
|
} |
| 320 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 321 |
0 |
@Override... |
| 322 |
|
public DavResourceFactory getFactory() |
| 323 |
|
{ |
| 324 |
0 |
return getContext().getResourceFactory(); |
| 325 |
|
} |
| 326 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 327 |
725 |
@Override... |
| 328 |
|
public DavResourceLocator getLocator() |
| 329 |
|
{ |
| 330 |
725 |
return this.locator; |
| 331 |
|
} |
| 332 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 333 |
2586 |
@Override... |
| 334 |
|
public String getResourcePath() |
| 335 |
|
{ |
| 336 |
2586 |
return this.locator.getResourcePath(); |
| 337 |
|
} |
| 338 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 339 |
6 |
@Override... |
| 340 |
|
public String getHref() |
| 341 |
|
{ |
| 342 |
6 |
return this.locator.getHref(isCollection()); |
| 343 |
|
} |
| 344 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 345 |
0 |
@Override... |
| 346 |
|
public DavSession getSession() |
| 347 |
|
{ |
| 348 |
0 |
return getContext().getDavSession(); |
| 349 |
|
} |
| 350 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 351 |
58 |
@Override... |
| 352 |
|
public DavResource getCollection() |
| 353 |
|
{ |
| 354 |
58 |
return this.parentResource; |
| 355 |
|
} |
| 356 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 357 |
1836 |
@Override... |
| 358 |
|
public XWikiDavContext getContext() |
| 359 |
|
{ |
| 360 |
1836 |
return context; |
| 361 |
|
} |
| 362 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 363 |
152 |
@Override... |
| 364 |
|
public List<XWikiDavResource> getVirtualMembers() |
| 365 |
|
{ |
| 366 |
152 |
Map<String, List<XWikiDavResource>> vResourcesMap = getContext().getUserStorage().getResourcesMap(); |
| 367 |
152 |
if (vResourcesMap.get(getResourcePath()) == null) { |
| 368 |
5 |
vResourcesMap.put(getResourcePath(), getInitMembers()); |
| 369 |
|
} |
| 370 |
152 |
return vResourcesMap.get(getResourcePath()); |
| 371 |
|
} |
| 372 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 373 |
856 |
@Override... |
| 374 |
|
public DavPropertySet getVirtualProperties() |
| 375 |
|
{ |
| 376 |
856 |
Map<String, DavPropertySet> vPropertiesMap = getContext().getUserStorage().getPropertiesMap(); |
| 377 |
856 |
if (vPropertiesMap.get(getResourcePath()) == null) { |
| 378 |
37 |
vPropertiesMap.put(getResourcePath(), new DavPropertySet()); |
| 379 |
|
} |
| 380 |
856 |
return vPropertiesMap.get(getResourcePath()); |
| 381 |
|
} |
| 382 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 383 |
3 |
@Override... |
| 384 |
|
public List<XWikiDavResource> getInitMembers() |
| 385 |
|
{ |
| 386 |
3 |
return new ArrayList<XWikiDavResource>(); |
| 387 |
|
} |
| 388 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 389 |
27 |
@Override... |
| 390 |
|
public void clearCache() |
| 391 |
|
{ |
| 392 |
27 |
Map<String, List<XWikiDavResource>> vResourcesMap = getContext().getUserStorage().getResourcesMap(); |
| 393 |
27 |
Map<String, DavPropertySet> vPropertiesMap = getContext().getUserStorage().getPropertiesMap(); |
| 394 |
27 |
vResourcesMap.remove(getResourcePath()); |
| 395 |
27 |
vPropertiesMap.remove(getResourcePath()); |
| 396 |
|
} |
| 397 |
|
|
| 398 |
|
|
| 399 |
|
|
| 400 |
|
|
| 401 |
|
@param@link |
| 402 |
|
@param@link |
| 403 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 2 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 404 |
6 |
public void addVirtualMember(DavResource resource, InputContext inputContext) throws DavException... |
| 405 |
|
{ |
| 406 |
6 |
XWikiDavResource davResource = (XWikiDavResource) resource; |
| 407 |
6 |
boolean isFile = (inputContext.getInputStream() != null); |
| 408 |
6 |
long modificationTime = inputContext.getModificationTime(); |
| 409 |
6 |
if (davResource instanceof DavTempFile) { |
| 410 |
6 |
DavTempFile tempFile = (DavTempFile) davResource; |
| 411 |
6 |
if (isFile) { |
| 412 |
2 |
byte[] data = null; |
| 413 |
2 |
data = getContext().getFileContentAsBytes(inputContext.getInputStream()); |
| 414 |
2 |
tempFile.update(data, new Date(modificationTime)); |
| 415 |
|
} else { |
| 416 |
4 |
tempFile.setModified(new Date(modificationTime)); |
| 417 |
|
} |
| 418 |
|
} |
| 419 |
|
|
| 420 |
6 |
if (!getVirtualMembers().contains(davResource)) { |
| 421 |
6 |
getVirtualMembers().add(davResource); |
| 422 |
|
} |
| 423 |
|
} |
| 424 |
|
|
| 425 |
|
|
| 426 |
|
|
| 427 |
|
|
| 428 |
|
@param@link |
| 429 |
|
|
| |
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 430 |
6 |
public void removeVirtualMember(DavResource member) throws DavException... |
| 431 |
|
{ |
| 432 |
6 |
XWikiDavResource davResource = (XWikiDavResource) member; |
| 433 |
6 |
if (getVirtualMembers().contains(davResource)) { |
| 434 |
6 |
getVirtualMembers().remove(davResource); |
| 435 |
6 |
davResource.clearCache(); |
| 436 |
|
} else { |
| 437 |
0 |
throw new DavException(DavServletResponse.SC_NOT_FOUND); |
| 438 |
|
} |
| 439 |
|
} |
| 440 |
|
|
| 441 |
|
|
| 442 |
|
|
| 443 |
|
|
| 444 |
|
|
| 445 |
|
|
| 446 |
|
|
| 447 |
|
|
| 448 |
|
|
| 449 |
|
|
| 450 |
|
|
| 451 |
|
|
| 452 |
|
|
| 453 |
|
@param |
| 454 |
|
@return |
| 455 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 456 |
147 |
public boolean isTempResource(String resourceName)... |
| 457 |
|
{ |
| 458 |
147 |
return resourceName.startsWith(".") |
| 459 |
|
|| resourceName.endsWith("~") |
| 460 |
|
|| resourceName.equals("mach_kernel") |
| 461 |
|
|| resourceName.equals("Backups.backupdb"); |
| 462 |
|
} |
| 463 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 464 |
0 |
@Override... |
| 465 |
|
public int hashCode() |
| 466 |
|
{ |
| 467 |
0 |
return getResourcePath().hashCode(); |
| 468 |
|
} |
| 469 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 470 |
105 |
@Override... |
| 471 |
|
public boolean equals(Object obj) |
| 472 |
|
{ |
| 473 |
105 |
if (obj instanceof DavResource) { |
| 474 |
105 |
DavResource other = (DavResource) obj; |
| 475 |
105 |
return getResourcePath().equals(other.getResourcePath()); |
| 476 |
|
} |
| 477 |
0 |
return false; |
| 478 |
|
} |
| 479 |
|
} |