Search in sources :

Example 1 with UploadValidationException

use of com.google.gerrit.server.git.validators.UploadValidationException in project gerrit by GerritCodeReview.

the class Upload method runImpl.

@Override
protected void runImpl() throws IOException, Failure {
    if (!projectControl.canRunUploadPack()) {
        throw new Failure(1, "fatal: upload-pack not permitted on this server");
    }
    final UploadPack up = new UploadPack(repo);
    up.setAdvertiseRefsHook(new VisibleRefFilter(tagCache, changeNotesFactory, changeCache, repo, projectControl, db, true));
    up.setPackConfig(config.getPackConfig());
    up.setTimeout(config.getTimeout());
    up.setPostUploadHook(PostUploadHookChain.newChain(Lists.newArrayList(postUploadHooks)));
    List<PreUploadHook> allPreUploadHooks = Lists.newArrayList(preUploadHooks);
    allPreUploadHooks.add(uploadValidatorsFactory.create(project, repo, session.getRemoteAddressAsString()));
    up.setPreUploadHook(PreUploadHookChain.newChain(allPreUploadHooks));
    try {
        up.upload(in, out, err);
        session.setPeerAgent(up.getPeerUserAgent());
    } catch (UploadValidationException e) {
        // internal server error to the client.
        if (!e.isOutput()) {
            up.sendMessage(e.getMessage());
        }
    }
}
Also used : PreUploadHook(org.eclipse.jgit.transport.PreUploadHook) UploadValidationException(com.google.gerrit.server.git.validators.UploadValidationException) UploadPack(org.eclipse.jgit.transport.UploadPack) VisibleRefFilter(com.google.gerrit.server.git.VisibleRefFilter)

Aggregations

VisibleRefFilter (com.google.gerrit.server.git.VisibleRefFilter)1 UploadValidationException (com.google.gerrit.server.git.validators.UploadValidationException)1 PreUploadHook (org.eclipse.jgit.transport.PreUploadHook)1 UploadPack (org.eclipse.jgit.transport.UploadPack)1