use of org.eclipse.jgit.transport.PreUploadHook 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());
}
}
}
Aggregations