List of usage examples for org.eclipse.jgit.lib Constants TYPE_BLOB
String TYPE_BLOB
To view the source code for org.eclipse.jgit.lib Constants TYPE_BLOB.
Click Source Link
From source file:com.google.gitiles.RevisionServlet.java
License:Open Source License
@Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { GitilesView view = ViewFilter.getView(req); Repository repo = ServletUtils.getRepository(req); RevWalk walk = new RevWalk(repo); try {/*from w ww . java 2 s . c o m*/ List<RevObject> objects = listObjects(walk, view.getRevision().getId()); List<Map<String, ?>> soyObjects = Lists.newArrayListWithCapacity(objects.size()); boolean hasBlob = false; // TODO(sop): Allow caching commits by SHA-1 when no S cookie is sent. for (RevObject obj : objects) { try { switch (obj.getType()) { case OBJ_COMMIT: soyObjects.add(ImmutableMap.of("type", Constants.TYPE_COMMIT, "data", new CommitSoyData(linkifier, req, repo, walk, view).toSoyData((RevCommit) obj, KeySet.DETAIL_DIFF_TREE))); break; case OBJ_TREE: soyObjects.add(ImmutableMap.of("type", Constants.TYPE_TREE, "data", new TreeSoyData(walk, view).toSoyData(obj))); break; case OBJ_BLOB: soyObjects.add(ImmutableMap.of("type", Constants.TYPE_BLOB, "data", new BlobSoyData(walk, view).toSoyData(obj))); hasBlob = true; break; case OBJ_TAG: soyObjects.add(ImmutableMap.of("type", Constants.TYPE_TAG, "data", new TagSoyData(linkifier, req).toSoyData((RevTag) obj))); break; default: log.warn("Bad object type for %s: %s", ObjectId.toString(obj.getId()), obj.getType()); res.setStatus(SC_NOT_FOUND); return; } } catch (MissingObjectException e) { log.warn("Missing object " + ObjectId.toString(obj.getId()), e); res.setStatus(SC_NOT_FOUND); return; } catch (IncorrectObjectTypeException e) { log.warn("Incorrect object type for " + ObjectId.toString(obj.getId()), e); res.setStatus(SC_NOT_FOUND); return; } } render(req, res, "gitiles.revisionDetail", ImmutableMap.of("title", view.getRevision().getName(), "objects", soyObjects, "hasBlob", hasBlob)); } finally { walk.release(); } }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java
License:Eclipse Distribution License
private void processBlob(final RevObject obj) throws TransportException { try {//w w w . j a v a2s . c o m if (reader.has(obj, Constants.OBJ_BLOB)) obj.add(COMPLETE); else throw new TransportException(MessageFormat.format(JGitText.get().cannotReadBlob, obj.name()), new MissingObjectException(obj, Constants.TYPE_BLOB)); } catch (IOException error) { throw new TransportException(MessageFormat.format(JGitText.get().cannotReadBlob, obj.name()), error); } }