Пример #1
0
 private EntityTag etag(DavResource resource) {
   if (resource == null) return null;
   String etag = resource.getETag();
   if (etag == null) return null;
   // resource etags have doublequotes wrapped around them
   if (etag.startsWith("\"")) etag = etag.substring(1, etag.length() - 1);
   return new EntityTag(etag);
 }
Пример #2
0
  private void ifModifiedSince(DavRequest request, DavResponse response, DavResource resource)
      throws DavException, IOException {
    if (resource == null) return;

    long mod = resource.getModificationTime();
    if (mod == -1) return;
    mod = mod / 1000 * 1000;

    long since = request.getDateHeader("If-Modified-Since");
    if (since == -1) return;

    if (mod > since) return;

    throw new NotModifiedException();
  }
Пример #3
0
  private void ifUnmodifiedSince(DavRequest request, DavResponse response, DavResource resource)
      throws DavException, IOException {
    if (resource == null) return;

    long mod = resource.getModificationTime();
    if (mod == -1) return;
    mod = mod / 1000 * 1000;

    long since = request.getDateHeader("If-Unmodified-Since");
    if (since == -1) return;

    if (mod <= since) return;

    throw new PreconditionFailedException("If-Unmodified-Since disallows conditional request");
  }
Пример #4
0
  /**
   * Hands the request off to a provider method for handling. The provider is created by calling
   * {@link #createProvider(DavResource)}. The specific provider method is chosen by examining the
   * request method.
   */
  protected void process(DavRequest request, DavResponse response, DavResource resource)
      throws IOException, DavException {
    DavProvider provider = createProvider(resource);

    if (request.getMethod().equals("OPTIONS")) options(request, response, resource);
    else if (request.getMethod().equals("GET")) provider.get(request, response, resource);
    else if (request.getMethod().equals("HEAD")) provider.head(request, response, resource);
    else if (request.getMethod().equals("PROPFIND")) provider.propfind(request, response, resource);
    else if (request.getMethod().equals("PROPPATCH"))
      provider.proppatch(request, response, resource);
    else if (request.getMethod().equals("DELETE")) provider.delete(request, response, resource);
    else if (request.getMethod().equals("COPY")) provider.copy(request, response, resource);
    else if (request.getMethod().equals("MOVE")) provider.move(request, response, resource);
    else if (request.getMethod().equals("REPORT")) provider.report(request, response, resource);
    else if (request.getMethod().equals("MKTICKET")) provider.mkticket(request, response, resource);
    else if (request.getMethod().equals("DELTICKET"))
      provider.delticket(request, response, resource);
    else if (request.getMethod().equals("ACL")) provider.acl(request, response, resource);
    else {
      if (resource.isCollection()) {
        if (request.getMethod().equals("MKCOL"))
          provider.mkcol(request, response, (DavCollection) resource);
        else if (request.getMethod().equals("MKCALENDAR"))
          provider.mkcalendar(request, response, (DavCollection) resource);
        else
          throw new MethodNotAllowedException(
              request.getMethod() + " not allowed for a collection");
      } else {
        if (request.getMethod().equals("PUT"))
          provider.put(request, response, (DavContent) resource);
        else
          throw new MethodNotAllowedException(
              request.getMethod() + " not allowed for a non-collection resource");
      }
    }
  }
Пример #5
0
 private void options(DavRequest request, DavResponse response, DavResource resource) {
   response.setStatus(200);
   response.addHeader("Allow", resource.getSupportedMethods());
   response.addHeader("DAV", resource.getComplianceClass());
 }