Пример #1
0
  protected void respondWithToken(LockToken tok, Request request, Response response) {
    response.setStatus(Status.SC_OK);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    XmlWriter writer = new XmlWriter(out);
    writer.writeXMLHeader();
    String d = WebDavProtocol.DAV_PREFIX;
    writer.open(d + ":prop  xmlns:" + d + "=\"DAV:\"");
    writer.newLine();
    writer.open(d + ":lockdiscovery");
    writer.newLine();
    writer.open(d + ":activelock");
    writer.newLine();
    lockWriterHelper.appendType(writer, tok.info.type);
    lockWriterHelper.appendScope(writer, tok.info.scope);
    lockWriterHelper.appendDepth(writer, tok.info.depth);
    lockWriterHelper.appendOwner(writer, tok.info.lockedByUser);
    lockWriterHelper.appendTimeout(writer, tok.timeout.getSeconds());
    lockWriterHelper.appendTokenId(writer, tok.tokenId);
    String url = PropFindPropertyBuilder.fixUrlForWindows(request.getAbsoluteUrl());
    lockWriterHelper.appendRoot(writer, url);
    writer.close(d + ":activelock");
    writer.close(d + ":lockdiscovery");
    writer.close(d + ":prop");
    writer.flush();

    LogUtils.debug(log, "lock response: ", out);
    response.setEntity(new ByteArrayEntity(out.toByteArray()));
    //        response.close();

  }
Пример #2
0
  @Override
  public void process(HttpManager manager, Request request, Response response)
      throws NotAuthorizedException, BadRequestException {
    if (!handlerHelper.checkExpects(responseHandler, request, response)) {
      return;
    }

    String host = request.getHostHeader();
    String url = HttpManager.decodeUrl(request.getAbsolutePath());

    // Find a resource if it exists
    Resource r = manager.getResourceFactory().getResource(host, url);
    if (r != null) {
      log.debug("locking existing resource: " + r.getName());
      processExistingResource(manager, request, response, r);
    } else {
      log.debug("lock target doesnt exist, attempting lock null..");
      processNonExistingResource(manager, request, response, host, url);
    }
  }
Пример #3
0
  protected void processExistingResource(
      HttpManager manager, Request request, Response response, Resource resource)
      throws NotAuthorizedException {
    if (handlerHelper.isNotCompatible(resource, request.getMethod()) || !isCompatible(resource)) {
      responseHandler.respondMethodNotImplemented(resource, response, request);
      return;
    }
    if (!handlerHelper.checkAuthorisation(manager, resource, request)) {
      responseHandler.respondUnauthorised(resource, response, request);
      return;
    }

    handlerHelper.checkExpects(responseHandler, request, response);

    LockableResource r = (LockableResource) resource;
    LockTimeout timeout = LockTimeout.parseTimeout(request);
    String ifHeader = request.getIfHeader();
    response.setContentTypeHeader(Response.XML);
    if (ifHeader == null || ifHeader.length() == 0) {
      processNewLock(manager, request, response, r, timeout);
    } else {
      processRefresh(manager, request, response, r, timeout, ifHeader);
    }
  }