/** @see IServer#unlock(ILocator, IContext) */
 public IResponse unlock(ILocator locator, IContext userContext) throws IOException {
   Assert.isNotNull(locator);
   Assert.isNotNull(userContext);
   IContext context = newContext(userContext, locator);
   Request request = newRequest(locator, context, "UNLOCK"); // $NON-NLS-1$
   return httpClient.invoke(request);
 }
Пример #2
0
  /**
   * Writes this messages body to the given output stream. This method may only be called once
   * during the lifetime of this message.
   *
   * @param os an output stream
   * @exception IOException if there is an I/O error
   */
  public void write(OutputStream os) throws IOException {
    Assert.isTrue(!inputRead);
    Assert.isTrue(!hasInputStream);

    int bytesRead = 0;
    int totalBytesRead = 0;
    byte[] buffer = bufferPool.getBuffer();
    long contentLength = getContentLength();

    try {
      while (bytesRead != -1 && (contentLength == -1 || contentLength > totalBytesRead)) {
        if (contentLength == -1) {
          bytesRead = is.read(buffer);
        } else {
          bytesRead =
              is.read(buffer, 0, (int) Math.min(buffer.length, contentLength - totalBytesRead));
        }
        if (bytesRead == -1) {
          if (contentLength >= 0) {
            throw new IOException(Policy.bind("exception.unexpectedEndStream")); // $NON-NLS-1$
          }
        } else {
          totalBytesRead += bytesRead;
          os.write(buffer, 0, bytesRead);
        }
      }
    } finally {
      bufferPool.putBuffer(buffer);
      inputRead = true;
    }
  }
 /** @see IServer#checkout(ILocator, IContext, Document) */
 public IResponse checkout(ILocator locator, IContext userContext, Document body)
     throws IOException {
   Assert.isNotNull(locator);
   Assert.isNotNull(userContext);
   IContext context = newContext(userContext, locator);
   Request request = newRequest(locator, context, body, "CHECKOUT"); // $NON-NLS-1$
   return httpClient.invoke(request);
 }
 /** @see IServer#baselineControl(ILocator, IContext, Document) */
 public IResponse baselineControl(ILocator locator, IContext userContext, Document document)
     throws IOException {
   Assert.isNotNull(locator);
   Assert.isNotNull(userContext);
   IContext context = newContext(userContext, locator);
   Request request = newRequest(locator, context, document, "BASELINE-CONTROL"); // $NON-NLS-1$
   return httpClient.invoke(request);
 }
 /** @see IServer#versionControl(ILocator, IContext, Document) */
 public IResponse versionControl(ILocator locator, IContext userContext, Document body)
     throws IOException {
   Assert.isNotNull(locator);
   Assert.isNotNull(userContext);
   IContext context = newContext(userContext, locator);
   Request request = newRequest(locator, context, body, "VERSION-CONTROL"); // $NON-NLS-1$
   return httpClient.invoke(request);
 }
 /** @see IServer#put(ILocator, IContext, InputStream) */
 public IResponse put(ILocator locator, IContext userContext, InputStream is) throws IOException {
   Assert.isNotNull(locator);
   Assert.isNotNull(userContext);
   Assert.isNotNull(is);
   IContext context = newContext(userContext, locator);
   Request request = newRequest(locator, context, is, "PUT"); // $NON-NLS-1$
   return httpClient.invoke(request);
 }
 /** @see IServer#propfind(ILocator, IContext, Document) */
 public IResponse propfind(ILocator locator, IContext userContext, Document document)
     throws IOException {
   Assert.isNotNull(locator);
   Assert.isNotNull(userContext);
   IContext context = newContext(userContext, locator);
   Request request = newRequest(locator, context, document, "PROPFIND"); // $NON-NLS-1$
   return httpClient.invoke(request);
 }
 /** @see IServer#mkworkspace(ILocator, IContext, Document) */
 public IResponse mkworkspace(ILocator locator, IContext userContext, Document document)
     throws IOException {
   Assert.isNotNull(locator);
   Assert.isNotNull(userContext);
   IContext context = newContext(userContext, locator);
   Request request = newRequest(locator, context, document, "MKWORKSPACE"); // $NON-NLS-1$
   return httpClient.invoke(request);
 }
 /** @see IServer#bind(ILocator, ILocator, IContext) */
 public IResponse bind(ILocator source, ILocator destination, IContext userContext)
     throws IOException {
   Assert.isNotNull(source);
   Assert.isNotNull(destination);
   Assert.isNotNull(userContext);
   IContext context = newContext(userContext, source);
   context.setDestination(URLEncoder.encode(destination.getResourceURL()));
   Request request = newRequest(source, context, "BIND"); // $NON-NLS-1$
   return httpClient.invoke(request);
 }