List of usage examples for org.eclipse.jgit.transport WalkFetchConnection WalkFetchConnection
WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w)
From source file:it.com.atlassian.labs.speakeasy.util.jgit.FixedTransportHttp.java
License:Eclipse Distribution License
private FetchConnection newDumbConnection(InputStream in) throws IOException, PackProtocolException { HttpObjectDB d = new HttpObjectDB(objectsUrl); BufferedReader br = toBufferedReader(in); Map<String, Ref> refs; try {//from w w w. j a v a2 s . com refs = d.readAdvertisedImpl(br); } finally { br.close(); } if (!refs.containsKey(Constants.HEAD)) { // If HEAD was not published in the info/refs file (it usually // is not there) download HEAD by itself as a loose file and do // the resolution by hand. // HttpURLConnection conn = httpOpen(new URL(baseUrl, Constants.HEAD)); int status = HttpSupport.response(conn); switch (status) { case HttpURLConnection.HTTP_OK: { br = toBufferedReader(openInputStream(conn)); try { String line = br.readLine(); if (line != null && line.startsWith(RefDirectory.SYMREF)) { String target = line.substring(RefDirectory.SYMREF.length()); Ref r = refs.get(target); if (r == null) r = new ObjectIdRef.Unpeeled(Ref.Storage.NEW, target, null); r = new SymbolicRef(Constants.HEAD, r); refs.put(r.getName(), r); } else if (line != null && ObjectId.isId(line)) { Ref r = new ObjectIdRef.Unpeeled(Ref.Storage.NETWORK, Constants.HEAD, ObjectId.fromString(line)); refs.put(r.getName(), r); } } finally { br.close(); } break; } case HttpURLConnection.HTTP_NOT_FOUND: break; default: throw new TransportException(uri, MessageFormat.format(JGitText.get().cannotReadHEAD, status, conn.getResponseMessage())); } } WalkFetchConnection wfc = new WalkFetchConnection(this, d); wfc.available(refs); return wfc; }