use of org.eclipse.jgit.transport.UploadPack in project gitblit by gitblit.
the class GitblitUploadPackFactory method create.
@Override
public UploadPack create(X req, Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException {
int timeout = 0;
if (req instanceof GitDaemonClient) {
// git daemon request is always anonymous
GitDaemonClient client = (GitDaemonClient) req;
// set timeout from Git daemon
timeout = client.getDaemon().getTimeout();
}
UploadPack up = new UploadPack(db);
up.setTimeout(timeout);
return up;
}
use of org.eclipse.jgit.transport.UploadPack in project gitblit by gitblit.
the class Upload method runImpl.
@Override
protected void runImpl() throws Failure {
try {
SshKey key = getContext().getClient().getKey();
if (key != null && !key.canClone()) {
throw new Failure(1, "Sorry, your SSH public key is not allowed to clone!");
}
UploadPack up = uploadPackFactory.create(getContext().getClient(), repo);
up.upload(in, out, null);
} catch (Exception e) {
throw new Failure(1, "fatal: Cannot upload pack: ", e);
}
}
use of org.eclipse.jgit.transport.UploadPack 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