@COPY
  public Message copy(
      @PathTranslated Path path, @Destination URI destinationUri, @Overwrite boolean overwrite)
      throws IOException {
    final Resource source = resolveResource(path);

    final Resource destination = resolveResource(Path.fromString(destinationUri.getPath()));

    if (destination.isLocked()) {
      return clientErrorLocked();
    }

    if (source.exists()) {
      if (source.isCollection()) { // source exists
        if (destination.exists()) { // source exists and is a collection
          if (destination.isCollection()) {
            return (overwrite
                ? copyCollectionToCollection(source, destination, overwrite)
                : clientErrorPreconditionFailed());
          } else {
            return (overwrite
                ? copyCollectionToResource(source, destination, overwrite)
                : clientErrorPreconditionFailed());
          }
        } else {
          return (destination.parent().exists()
              ? copyCollectionToCollection(source, destination, false)
              : clientErrorPreconditionFailed());
        }
      } else {
        if (destination.exists()) { // source exists
          if (destination.isCollection()) { // source exists,
            return (overwrite
                ? copyResourceToCollection(source, destination, overwrite)
                : clientErrorPreconditionFailed());
          } else {
            return (overwrite
                ? copyResourceToResource(source, destination, overwrite)
                : clientErrorPreconditionFailed());
          }
        } else {
          if (destination.parent().exists()) {
            return (overwrite
                ? clientErrorPreconditionFailed()
                : copyResourceToCollection(source, destination, overwrite));
          } else {
            return clientErrorConflict();
          }
        }
      }
    } else {
      return clientErrorNotFound();
    }
  }
  private Message propfind(Path path, Depth depth, ByteBuffer body) throws IOException {
    final Resource resource = resolveResource(path);

    final Iterable<QName> properties = getProperties(body);
    final List<RESPONSE> responses = propfind(properties, resource, depth);
    if (resource.exists()) {
      return successMultiStatus(multistatus(responses));
    } else {
      return clientErrorNotFound();
    }
  }
 private Response doGet(Environment env) {
   Path path = env.pathInfo();
   Resource resource = resolveResource(path);
   if (resource.exists()) {
     if (resource.isCollection()) {
       return clientErrorNotFound();
     } else {
       return getResource(request);
     }
   } else {
     return clientErrorNotFound();
   }
 }
  private Response doUnlock(Environment env) {
    final Resource resource = resolveResource(env.pathInfo());

    if (resource.exists()) {
      if (resource.isLocked()) {
        resource.unlock();
        return successNoContent();
      } else {
        return clientErrorLocked();
      }
    } else {
      return clientErrorNotFound();
    }
  }
  @PUT
  public Message put(@PathTranslated Path path, @Context Request request) throws IOException {
    final Resource resource = resolveResource(path);
    if (!resource.parent().exists()) {
      return clientErrorConflict();
    }

    if (resource.exists() && resource.isCollection()) {
      return clientErrorMethodNotAllowed();
    }

    ByteBuffer entity = request.buffer();
    resource.put(entity);
    return successCreated();
  }
  @MKCOL
  public Message mkcol(@PathTranslated Path path, @Context Request request) {
    final Resource resource = resolveResource(path);

    if (request.hasBody()) {
      return clientErrorUnsupportedMediaType();
    } else {
      if (resource.exists()) {
        return clientErrorMethodNotAllowed();
      } else {
        if (resource.parent().exists()) {
          return (resource.mkcol() ? successCreated() : serverErrorInternal());
        } else {
          return clientErrorConflict();
        }
      }
    }
  }
  @LOCK
  public Message lock(@PathTranslated Path path, Depth depth) throws IOException {
    final Resource resource = resolveResource(path);

    if (resource.exists()) {
      final Lock lock = resource.lock(WRITE, EXCLUSIVE);

      final ACTIVE_LOCK activelock = activeLock(lock, depth, relativizeResource(resource));
      final Element lockDiscovery = lockDiscovery(activelock);
      final Element prop = prop(lockDiscovery);
      final Document doc = new Document(XML_DECLARATION, prop);
      return Response.build(SUCCESS_OK)
          .header(LOCK_TOKEN)
          .set("<" + lock.token() + ">")
          .setBody(Charset.defaultCharset().encode(XMLWriter.write(doc)));
    } else {
      return clientErrorNotFound();
    }
  }
  private Response doDelete(Environment env) {
    final Resource resource = resolveResource(env.pathInfo());

    //		if (fragment != null) {
    //			return clientErrorMethodNotAllowed();
    //		} else {
    if (resource.isLocked()) {
      return clientErrorLocked();
    }
    if (resource.exists()) {
      if (resource.isLocked()) {
        return clientErrorLocked();
      } else {
        if (resource.isCollection()) {
          return (resource.delete() ? successNoContent() : serverErrorInternal());
        } else {
          return (resource.delete() ? successNoContent() : serverErrorInternal());
        }
      }
    } else {
      return clientErrorNotFound();
    }
    //		}
  }