Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.ReceivePack


    SshKey key = getContext().getClient().getKey();
    if (key != null && !key.canPush()) {
      throw new Failure(1, "Sorry, your SSH public key is not allowed to push changes!");
    }
    try {
      ReceivePack rp = receivePackFactory.create(getContext().getClient(), repo);
      rp.receive(in, out, null);
    } catch (Exception e) {
      throw new Failure(1, "fatal: Cannot receive pack: ", e);
    }
  }
View Full Code Here


          @Override
          protected void execute(final GitDaemonClient dc, final Repository db)
              throws IOException, ServiceNotEnabledException,
              ServiceNotAuthorizedException {
            ReceivePack rp = receivePackFactory.create(dc, db);
            InputStream in = dc.getInputStream();
            OutputStream out = dc.getOutputStream();
            rp.receive(in, out, null);
          }
        } };
  }
View Full Code Here

      HttpServletResponse res, String textForGit) throws IOException {
    ByteArrayOutputStream buf = new ByteArrayOutputStream(128);
    PacketLineOut pckOut = new PacketLineOut(buf);

    boolean sideband;
    ReceivePack rp = (ReceivePack) req.getAttribute(ATTRIBUTE_HANDLER);
    if (rp != null) {
      try {
        sideband = rp.isSideBand();
      } catch (RequestNotYetReadException e) {
        sideband = isReceivePackSideBand(req);
      }
    } else
      sideband = isReceivePackSideBand(req);
View Full Code Here

    });
    gs.setReceivePackFactory(new DefaultReceivePackFactory() {
      public ReceivePack create(HttpServletRequest req, Repository db)
          throws ServiceNotEnabledException,
          ServiceNotAuthorizedException {
        ReceivePack recv = super.create(req, db);
        recv.setPreReceiveHook(new PreReceiveHook() {
          public void onPreReceive(ReceivePack rp,
              Collection<ReceiveCommand> commands) {
            rp.sendMessage("message line 1");
            rp.sendError("no soup for you!");
            rp.sendMessage("come back next year!");
View Full Code Here

    });
    gs.setReceivePackFactory(new DefaultReceivePackFactory() {
      public ReceivePack create(HttpServletRequest req, Repository db)
          throws ServiceNotEnabledException,
          ServiceNotAuthorizedException {
        ReceivePack rp = super.create(req, db);
        rp.sendError("message line 1");
        rp.sendError("no soup for you!");
        rp.sendError("come back next year!");
        return rp;
      }

    });
    app.addServlet(new ServletHolder(gs), "/*");
 
View Full Code Here

  }

  @Test
  public void testCreate_AuthUser() throws ServiceNotEnabledException,
      ServiceNotAuthorizedException {
    ReceivePack rp;
    rp = factory.create(new R("bob", "1.2.3.4"), db);
    assertNotNull("have ReceivePack", rp);
    assertSame(db, rp.getRepository());

    PersonIdent id = rp.getRefLogIdent();
    assertNotNull(id);
    assertEquals("bob", id.getName());
    assertEquals("bob@1.2.3.4", id.getEmailAddress());

    // Should have inherited off the current system, which is mocked
View Full Code Here

      ServiceNotAuthorizedException, IOException {
    final StoredConfig cfg = db.getConfig();
    cfg.setBoolean("http", null, "receivepack", true);
    cfg.save();

    ReceivePack rp;

    rp = factory.create(new R(null, "1.2.3.4"), db);
    assertNotNull("have ReceivePack", rp);
    assertSame(db, rp.getRepository());

    PersonIdent id = rp.getRefLogIdent();
    assertNotNull(id);
    assertEquals("anonymous", id.getName());
    assertEquals("anonymous@1.2.3.4", id.getEmailAddress());

    // Should have inherited off the current system, which is mocked
View Full Code Here

    });
    gs.setReceivePackFactory(new DefaultReceivePackFactory() {
      public ReceivePack create(HttpServletRequest req, Repository db)
          throws ServiceNotEnabledException,
          ServiceNotAuthorizedException {
        ReceivePack recv = super.create(req, db);
        recv.setPostReceiveHook(new PostReceiveHook() {

          public void onPostReceive(ReceivePack rp,
              Collection<ReceiveCommand> commands) {
            packSize = rp.getPackSize();
          }
View Full Code Here

    verifyProjectVisible("CC", ccId);

    receive.addReviewers(reviewerId);
    receive.addExtraCC(ccId);

    final ReceivePack rp = receive.getReceivePack();
    rp.setRefLogIdent(currentUser.newRefLogIdent());
    rp.setTimeout(config.getTimeout());
    rp.setMaxObjectSizeLimit(config.getMaxObjectSizeLimit());
    try {
      receive.advertiseHistory();
      rp.receive(in, out, err);
    } catch (UnpackException badStream) {
      // In case this was caused by the user pushing an object whose size
      // is larger than the receive.maxObjectSizeLimit gerrit.config parameter
      // we want to present this error to the user
      if (badStream.getCause() instanceof TooLargeObjectInPackException) {
        StringBuilder msg = new StringBuilder();
        msg.append("Receive error on project \""
            + projectControl.getProject().getName() + "\"");
        msg.append(" (user ");
        msg.append(currentUser.getAccount().getUserName());
        msg.append(" account ");
        msg.append(currentUser.getAccountId());
        msg.append("): ");
        msg.append(badStream.getCause().getMessage());
        log.info(msg.toString());
        throw new UnloggedFailure(128, "error: " + badStream.getCause().getMessage());
      }

      // This may have been triggered by branch level access controls.
      // Log what the heck is going on, as detailed as we can.
      //
      StringBuilder msg = new StringBuilder();
      msg.append("Unpack error on project \""
          + projectControl.getProject().getName() + "\":\n");

      msg.append("  AdvertiseRefsHook: " + rp.getAdvertiseRefsHook());
      if (rp.getAdvertiseRefsHook() == AdvertiseRefsHook.DEFAULT) {
        msg.append("DEFAULT");
      } else if (rp.getAdvertiseRefsHook() instanceof VisibleRefFilter) {
        msg.append("VisibleRefFilter");
      } else {
        msg.append(rp.getAdvertiseRefsHook().getClass());
      }
      msg.append("\n");

      if (rp.getAdvertiseRefsHook() instanceof VisibleRefFilter) {
        Map<String, Ref> adv = rp.getAdvertisedRefs();
        msg.append("  Visible references (" + adv.size() + "):\n");
        for (Ref ref : adv.values()) {
          msg.append("  - " + ref.getObjectId().abbreviate(8).name() + " "
              + ref.getName() + "\n");
        }

        List<Ref> hidden = new ArrayList<Ref>();
        for (Ref ref : rp.getRepository().getAllRefs().values()) {
          if (!adv.containsKey(ref.getName())) {
            hidden.add(ref);
          }
        }
View Full Code Here

    }
  }

  public void testCreate_AuthUser() throws ServiceNotEnabledException,
      ServiceNotAuthorizedException {
    ReceivePack rp;
    rp = factory.create(new R("bob", "1.2.3.4"), db);
    assertNotNull("have ReceivePack", rp);
    assertSame(db, rp.getRepository());

    PersonIdent id = rp.getRefLogIdent();
    assertNotNull(id);
    assertEquals("bob", id.getName());
    assertEquals("bob@1.2.3.4", id.getEmailAddress());

    // Should have inherited off the current system, which is mocked
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.transport.ReceivePack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.