Example usage for org.eclipse.jgit.errors CorruptObjectException CorruptObjectException

List of usage examples for org.eclipse.jgit.errors CorruptObjectException CorruptObjectException

Introduction

In this page you can find the example usage for org.eclipse.jgit.errors CorruptObjectException CorruptObjectException.

Prototype

public CorruptObjectException(String why) 

Source Link

Document

Construct a CorruptObjectException for reporting a problem not associated with a specific object id.

Usage

From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java

License:Eclipse Distribution License

private void processTree(final RevObject obj) throws TransportException {
    try {/* w ww  .j  av  a2 s . c o  m*/
        treeWalk.reset(obj);
        while (treeWalk.next()) {
            final FileMode mode = treeWalk.getFileMode(0);
            final int sType = mode.getObjectType();

            switch (sType) {
            case Constants.OBJ_BLOB:
            case Constants.OBJ_TREE:
                treeWalk.getObjectId(idBuffer, 0);
                needs(revWalk.lookupAny(idBuffer, sType));
                continue;

            default:
                if (FileMode.GITLINK.equals(mode))
                    continue;
                treeWalk.getObjectId(idBuffer, 0);
                throw new CorruptObjectException(MessageFormat.format(JGitText.get().invalidModeFor, mode,
                        idBuffer.name(), treeWalk.getPathString(), obj.getId().name()));
            }
        }
    } catch (IOException ioe) {
        throw new TransportException(MessageFormat.format(JGitText.get().cannotReadTree, obj.name()), ioe);
    }
    obj.add(COMPLETE);
}

From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java

License:Eclipse Distribution License

private void markTreeComplete(final RevTree tree) throws IOException {
    if (tree.has(COMPLETE))
        return;// w  ww  . jav a2 s .  co m
    tree.add(COMPLETE);
    treeWalk.reset(tree);
    while (treeWalk.next()) {
        final FileMode mode = treeWalk.getFileMode(0);
        final int sType = mode.getObjectType();

        switch (sType) {
        case Constants.OBJ_BLOB:
            treeWalk.getObjectId(idBuffer, 0);
            revWalk.lookupAny(idBuffer, sType).add(COMPLETE);
            continue;

        case Constants.OBJ_TREE: {
            treeWalk.getObjectId(idBuffer, 0);
            final RevObject o = revWalk.lookupAny(idBuffer, sType);
            if (!o.has(COMPLETE)) {
                o.add(COMPLETE);
                treeWalk.enterSubtree();
            }
            continue;
        }
        default:
            if (FileMode.GITLINK.equals(mode))
                continue;
            treeWalk.getObjectId(idBuffer, 0);
            throw new CorruptObjectException(MessageFormat.format(JGitText.get().corruptObjectInvalidMode3,
                    mode, idBuffer.name(), treeWalk.getPathString(), tree.name()));
        }
    }
}