public IResponse handleGet(String[] queryPath, Properties params) {
    IResponse response;
    if (queryPath.length == 0) {
      response = listBundles();
    } else if (queryPath.length == 1) {
      try {
        Bundle bundle = findBundle(queryPath[0]);
        Properties props = createBundleProperties(bundle);

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        props.store(buffer, null);

        response =
            new DefaultResponse(IResponse.HTTP_OK, IResponse.MIME_PLAINTEXT, buffer.toString());
      } catch (NumberFormatException e) {
        response = DefaultResponse.createBadRequestError(e.getMessage());
      } catch (IllegalArgumentException e) {
        response =
            new DefaultResponse(
                IResponse.HTTP_NOTFOUND, IResponse.MIME_PLAINTEXT, "No such bundle");
      } catch (IOException e) {
        response = DefaultResponse.createInternalError(e);
      }
    } else {
      response =
          new DefaultResponse(
              IResponse.HTTP_NOTIMPLEMENTED, IResponse.MIME_PLAINTEXT, "Not implemented.");
    }
    return response;
  }
  public IResponse handlePost(
      String[] queryPath, Properties params, Properties uploads, InputStream content) {
    IResponse response;
    if (queryPath.length == 0) {
      try {
        String startProp = params.getProperty("start");
        boolean start = "true".equals(startProp) || "on".equals(startProp);

        List errors = installBundles(uploads, start);
        if (errors.isEmpty()) response = listBundles();
        else response = listErrors(IResponse.HTTP_INTERNALERROR, errors);
      } catch (IllegalArgumentException e) {
        response =
            new DefaultResponse(
                IResponse.HTTP_BADREQUEST, IResponse.MIME_PLAINTEXT, e.getMessage());
      }
    } else {
      try {
        Bundle bundle = findBundle(queryPath[0]);
        if (queryPath.length == 1 && uploads != null && !uploads.isEmpty()) {
          updateBundle(bundle, uploads);
        } else if (queryPath.length == 2 && "start".equals(queryPath[1])) {
          bundle.start();
        } else if (queryPath.length == 2 && "stop".equals(queryPath[1])) {
          bundle.stop();
        } else if (queryPath.length == 2 && "update".equals(queryPath[1])) {
          bundle.update();
        }
        response = listBundles();
      } catch (NumberFormatException e) {
        response =
            new DefaultResponse(
                IResponse.HTTP_BADREQUEST, IResponse.MIME_PLAINTEXT, e.getMessage());
      } catch (FileNotFoundException e) {
        response = DefaultResponse.createInternalError(e);
      } catch (BundleException e) {
        response = DefaultResponse.createInternalError(e);
      } catch (IllegalArgumentException e) {
        response = DefaultResponse.createBadRequestError(e.getMessage());
      }
    }

    return response;
  }