Ejemplo n.º 1
0
  @Override
  public void doPost(final HttpServletRequest req, final HttpServletResponse rsp)
      throws IOException {
    if (!REQ_TYPE.equals(req.getContentType())) {
      rsp.sendError(SC_UNSUPPORTED_MEDIA_TYPE);
      return;
    }

    final Repository db = getRepository(req);
    try {
      final UploadPack up = uploadPackFactory.create(req, db);
      up.setBiDirectionalPipe(false);
      rsp.setContentType(RSP_TYPE);

      final SmartOutputStream out = new SmartOutputStream(req, rsp);
      up.upload(getInputStream(req), out, null);
      out.close();

    } catch (ServiceNotAuthorizedException e) {
      rsp.reset();
      rsp.sendError(SC_UNAUTHORIZED);
      return;

    } catch (ServiceNotEnabledException e) {
      rsp.reset();
      rsp.sendError(SC_FORBIDDEN);
      return;

    } catch (IOException e) {
      getServletContext().log("Internal error during upload-pack", e);
      rsp.reset();
      rsp.sendError(SC_INTERNAL_SERVER_ERROR);
      return;
    }
  }
Ejemplo n.º 2
0
 @Override
 protected void advertise(HttpServletRequest req, Repository db, PacketLineOutRefAdvertiser pck)
     throws IOException, ServiceNotEnabledException, ServiceNotAuthorizedException {
   uploadPackFactory.create(req, db).sendAdvertisedRefs(pck);
 }