List of usage examples for org.eclipse.jgit.transport UploadPack setBiDirectionalPipe
public void setBiDirectionalPipe(boolean twoWay)
From source file:org.webcat.core.git.http.UploadPackRequestHandler.java
License:Open Source License
/** * Handles the request and generates the UploadPack response. * * @param request the request/*from ww w . j a v a 2 s . c o m*/ * @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 (UPLOAD_PACK_REQUEST_TYPE.equals(contentType)) { Repository repo = RepositoryRequestUtils.repositoryFromRequest(request); UploadPack up = new UploadPack(repo); up.setBiDirectionalPipe(false); response.setHeader(UPLOAD_PACK_RESULT_TYPE, HttpSupport.HDR_CONTENT_TYPE); InputStream input = RequestUtils.inputStreamForRequest(request); SmartGZIPOutputStream output = new SmartGZIPOutputStream(request, response); up.upload(input, output, null); output.close(); } else { response.setStatus(HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE); } }
From source file:playRepository.RepositoryService.java
License:Apache License
/** * @see <a href="https://www.kernel.org/pub/software/scm/git/docs/git-upload-pack.html">git-upload-pack</a> * @see <a href="https://www.kernel.org/pub/software/scm/git/docs/git-receive-pack.html">git-receive-pack</a> *//*from ww w . j a va 2s . com*/ public static byte[] gitAdvertise(Project project, String service, Response response) throws IOException { response.setContentType("application/x-" + service + "-advertisement"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); PacketLineOut packetLineOut = new PacketLineOut(byteArrayOutputStream); packetLineOut.writeString("# service=" + service + "\n"); packetLineOut.end(); PacketLineOutRefAdvertiser packetLineOutRefAdvertiser = new PacketLineOutRefAdvertiser(packetLineOut); if (service.equals("git-upload-pack")) { Repository repository = GitRepository.buildGitRepository(project); UploadPack uploadPack = new UploadPack(repository); uploadPack.setBiDirectionalPipe(false); uploadPack.sendAdvertisedRefs(packetLineOutRefAdvertiser); } else if (service.equals("git-receive-pack")) { Repository repository = GitRepository.buildGitRepository(project, false); ReceivePack receivePack = new ReceivePack(repository); receivePack.sendAdvertisedRefs(packetLineOutRefAdvertiser); } byteArrayOutputStream.close(); return byteArrayOutputStream.toByteArray(); }
From source file:playRepository.RepositoryService.java
License:Apache License
private static void uploadPack(final InputStream input, Repository repository, final OutputStream output) { final UploadPack uploadPack = new UploadPack(repository); uploadPack.setBiDirectionalPipe(false); new Thread() { @Override//w ww.ja v a 2s .c om public void run() { try { uploadPack.upload(input, output, null); } catch (IOException e) { Logger.error("uploadPack failed", e); } closeStreams("uploadPack", input, output); } }.start(); }