protected static void storeData(
      IOObject ioobject, String location, RemoteRepository repository, ProgressListener l)
      throws RepositoryException {
    if (l != null) {
      l.setTotal(100);
      l.setCompleted(0);
    }

    HttpURLConnection conn;
    try {
      conn = repository.getResourceHTTPConnection(location, EntryStreamType.IOOBJECT, false);
    } catch (IOException e1) {
      throw new RepositoryException("Cannot store object at " + location + ": " + e1, e1);
    }
    OutputStream out = null;
    try {
      conn.setRequestProperty("Content-Type", RMContentType.IOOBJECT.getContentTypeString());
      conn.setRequestMethod("POST");
      conn.setDoOutput(true);
      conn.setDoInput(true);
      try {
        out = conn.getOutputStream();
      } catch (IOException e) {
        throw new RepositoryException(
            "Cannot upload object: " + conn.getResponseCode() + ": " + conn.getResponseMessage(),
            e);
      }
      IOObjectSerializer.getInstance().serialize(out, ioobject);
      out.close();
      BufferedReader in = null;
      try {
        try {
          in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
          LogService.getRoot().fine("BEGIN Reply of server:");
          String line;
          while ((line = in.readLine()) != null) {
            LogService.getRoot().fine(line);
          }
          LogService.getRoot().fine("END Reply of server.");
        } catch (IOException e) {
        }
      } finally {
        try {
          if (in != null) {
            in.close();
          }
        } catch (IOException e) {
        }
      }
    } catch (IOException e) {
      try {
        throw new RepositoryException(
            "Cannot store object at "
                + location
                + ": "
                + conn.getResponseCode()
                + ": "
                + conn.getResponseMessage(),
            e);
      } catch (IOException e1) {
        throw new RepositoryException("Cannot store object at " + location + ": " + e, e);
      }
    } finally {
      if (out != null) {
        try {
          out.close();
        } catch (IOException e) {
        }
      }
    }

    if (l != null) {
      l.setCompleted(100);
      l.complete();
    }
  }