List of usage examples for org.eclipse.jgit.transport UploadPack getMessageOutputStream
public OutputStream getMessageOutputStream()
From source file:com.googlesource.gerrit.plugins.motd.DisplayMotd.java
License:Apache License
@Override public void onPreUpload(Repository repository, Project project, String remote, UploadPack up, Collection<? extends ObjectId> wants, Collection<? extends ObjectId> haves) throws ValidationException { PrintWriter pw = new PrintWriter(up.getMessageOutputStream()); if (config.getMotd() != null) { pw.print(format(config.getMotd())); pw.print("\n"); }//ww w. j av a 2 s.com try { String inet = InetAddress.getByName(remote).getHostAddress(); for (Subnet m : config.getSubnets()) { if (m.isInRange(inet) && m.getMotd() != null) { pw.print(format(m.getMotd())); pw.print("\n"); break; } } } catch (UnknownHostException e) { // Couldn't look up the hostname; this is non-fatal } pw.flush(); }