List of usage examples for org.eclipse.jgit.transport ReceivePack setBiDirectionalPipe
public void setBiDirectionalPipe(boolean twoWay)
From source file:org.webcat.core.git.http.ReceivePackRequestHandler.java
License:Open Source License
/** * Handles the request and generates the ReceivePack response. * * @param request the request//from ww w . j a v a2 s.c om * @param response the response * @throws Exception if an error occurs */ public void handleRequest(WORequest request, WOResponse response) throws Exception { String contentType = request.headerForKey(HttpSupport.HDR_CONTENT_TYPE); if (RECEIVE_PACK_REQUEST_TYPE.equals(contentType)) { final Repository repo = RepositoryRequestUtils.repositoryFromRequest(request); ReceivePack rp = new ReceivePack(repo); rp.setBiDirectionalPipe(false); rp.setPostReceiveHook(new PostReceiveHook() { public void onPostReceive(ReceivePack pack, Collection<ReceiveCommand> commands) { // Once the pack is received, force a pull of the working // copy so that anyone using Web-DAV will get synched. GitUtilities.workingCopyForRepository(repo, true); } }); response.setHeader(RECEIVE_PACK_RESULT_TYPE, HttpSupport.HDR_CONTENT_TYPE); InputStream input = RequestUtils.inputStreamForRequest(request); SmartGZIPOutputStream output = new SmartGZIPOutputStream(request, response); rp.receive(input, output, null); output.close(); } else { response.setStatus(HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE); } }
From source file:playRepository.RepositoryService.java
License:Apache License
private static void receivePack(final InputStream input, Repository repository, final OutputStream output, final PreReceiveHook preReceiveHook, final PostReceiveHook postReceiveHook) { final ReceivePack receivePack = new ReceivePack(repository); receivePack.setBiDirectionalPipe(false); new Thread() { @Override//from w w w . j a v a2 s. c o m public void run() { try { receivePack.setPreReceiveHook(preReceiveHook); receivePack.setPostReceiveHook(postReceiveHook); receivePack.receive(input, output, null); } catch (IOException e) { Logger.error("receivePack failed", e); } closeStreams("receivePack", input, output); } }.start(); }