/** * (from the spec) 7.4 Write Locks and Null Resources * * <p>It is possible to assert a write lock on a null resource in order to lock the name. * * <p>A write locked null resource, referred to as a lock-null resource, MUST respond with a 404 * (Not Found) or 405 (Method Not Allowed) to any HTTP/1.1 or DAV methods except for PUT, MKCOL, * OPTIONS, PROPFIND, LOCK, and UNLOCK. A lock-null resource MUST appear as a member of its parent * collection. Additionally the lock-null resource MUST have defined on it all mandatory DAV * properties. Most of these properties, such as all the get* properties, will have no value as a * lock-null resource does not support the GET method. Lock-Null resources MUST have defined * values for lockdiscovery and supportedlock properties. * * <p>Until a method such as PUT or MKCOL is successfully executed on the lock-null resource the * resource MUST stay in the lock-null state. However, once a PUT or MKCOL is successfully * executed on a lock-null resource the resource ceases to be in the lock-null state. * * <p>If the resource is unlocked, for any reason, without a PUT, MKCOL, or similar method having * been successfully executed upon it then the resource MUST return to the null state. * * @param manager * @param request * @param response * @param host * @param url */ private void processNonExistingResource( HttpManager manager, Request request, Response response, String host, String url) throws NotAuthorizedException, BadRequestException { String name; Path parentPath = Path.path(url); name = parentPath.getName(); parentPath = parentPath.getParent(); url = parentPath.toString(); Resource r = manager.getResourceFactory().getResource(host, url); if (r != null) { if (!handlerHelper.checkAuthorisation(manager, r, request)) { responseHandler.respondUnauthorised(r, response, request); return; } else { processCreateAndLock(manager, request, response, r, name); } } else { log.debug("couldnt find parent to execute lock-null, returning not found"); // respondNotFound(response,request); response.setStatus(Status.SC_CONFLICT); } }
@Override public Resource getResource(String host, String sPath) throws NotAuthorizedException, BadRequestException { Path p = Path.path(sPath); if (p.getName().startsWith("alt-")) { Resource r = wrapped.getResource(host, p.getParent().toString()); if (r instanceof FileResource) { FileResource fr = (FileResource) r; String sourceHash = fr.getHash(); String formatName = p.getName().replace("alt-", ""); AltFormat f = AltFormat.find(sourceHash, formatName, SessionManager.session()); FormatSpec format = altFormatGenerator.findFormat(formatName); if (f != null) { return new AltFormatResource((FileResource) r, p.getName(), f, format); } else { log.warn( "getResource: pre-generated alt format not found: " + sourceHash + " - " + p.getName()); // if the format is valid then create a resource which will generate on demand if (format != null) { System.out.println("created resource for format: " + format); return new AltFormatResource((FileResource) r, p.getName(), format); } else { log.warn("getResource: unrecognised format: " + formatName); } return null; } } else { return null; } } else { return wrapped.getResource(host, sPath); } }