List of usage examples for org.eclipse.jgit.transport UploadPack sendMessage
public void sendMessage(String what)
From source file:com.google.gerrit.sshd.commands.Upload.java
License:Apache License
@Override protected void runImpl() throws IOException, Failure { if (!projectControl.canRunUploadPack()) { throw new Failure(1, "fatal: upload-pack not permitted on this server"); }// w w w . java2 s . co m final UploadPack up = new UploadPack(repo); if (!projectControl.allRefsAreVisible()) { up.setAdvertiseRefsHook( new VisibleRefFilter(tagCache, changeCache, repo, projectControl, db.get(), true)); } up.setPackConfig(config.getPackConfig()); up.setTimeout(config.getTimeout()); 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); } catch (UploadValidationException e) { // UploadValidationException is used by the UploadValidators to // stop the uploadPack. We do not want this exception to go beyond this // point otherwise it would print a stacktrace in the logs and return an // internal server error to the client. if (!e.isOutput()) { up.sendMessage(e.getMessage()); } } }
From source file:com.googlesource.gerrit.plugins.cookbook.DenyUploadExample.java
License:Apache License
@Override public void onPreUpload(Repository repository, Project project, String remoteHost, UploadPack up, Collection<? extends ObjectId> wants, Collection<? extends ObjectId> haves) throws ValidationException { up.sendMessage("Validating project name for " + user.getUserName() + "\n"); up.sendMessage(" from host: " + remoteHost + "\n"); if (project.getName().equals("deny-upload-project")) { throw new ValidationException("This error message was sent from cookbook plugin DenyUploadExample."); }/* ww w . j av a 2 s . c o m*/ }
From source file:com.googlesource.gerrit.plugins.examples.validationlistenerupload.DenyUploadExample.java
License:Apache License
@Override public void onPreUpload(Repository repository, Project project, String remoteHost, UploadPack up, Collection<? extends ObjectId> wants, Collection<? extends ObjectId> haves) throws ValidationException { up.sendMessage("Validating project name for " + user.getUserName() + "\n"); up.sendMessage(" from host: " + remoteHost + "\n"); if (project.getName().equals("deny-upload-project")) { throw new ValidationException( "This error message was sent from example-validationListenerUpload plugin DenyUploadExample."); }//from w w w . j av a 2s .c o m }