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, Throwable cause) 

Source Link

Document

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

Usage

From source file:jetbrains.buildServer.buildTriggers.vcs.git.submodules.SubmoduleAwareTreeIterator.java

License:Apache License

/**
 * Move iterator to the specific entry./*from  w  ww . jav a2s . co m*/
 *
 * @throws CorruptObjectException in case of submodule processing problem
 */
protected void movedToEntry() throws CorruptObjectException {
    myIsEof = eof();
    if (myIsEof) {
        return;
    }
    int wrappedMode = myWrappedIterator.getEntryRawMode();
    myIsOnSubmodule = checkoutSubmodules() && GITLINK_MODE_BITS == wrappedMode;
    mode = myIsOnSubmodule ? TREE_MODE_BITS : wrappedMode;
    if (myIsOnSubmodule) {
        String entryPath = myWrappedIterator.getEntryPathString();
        try {
            mySubmoduleCommit = getSubmoduleCommit(entryPath, myWrappedIterator.getEntryObjectId());
        } catch (Exception e) {
            if (mySubmodulesPolicy.isIgnoreSubmodulesErrors()) {
                if (myLogSubmoduleErrors)
                    LOG.warn("Ignore submodule error: \"" + e.getMessage()
                            + "\". It seems to be fixed in one of the later commits.");
                mySubmoduleCommit = null;
                myIsOnSubmodule = false;
                mySubmoduleError = true;
                mode = wrappedMode;
            } else {
                if (e instanceof CorruptObjectException) {
                    throw (CorruptObjectException) e;
                } else {
                    CorruptObjectException ex = new CorruptObjectException(myWrappedIterator.getEntryObjectId(),
                            e.getMessage());
                    ex.initCause(e);
                    throw ex;
                }
            }
        }
        if (myIdBuffer == null) {
            myIdBuffer = new byte[Constants.OBJECT_ID_LENGTH];
        }
        if (mySubmoduleCommit != null) {
            mySubmoduleCommit.getTree().getId().copyRawTo(myIdBuffer, 0);
        }
    } else {
        mySubmoduleCommit = null;
    }
    // copy name
    final int nameLength = myWrappedIterator.getNameLength();
    final int pathLength = nameLength + pathOffset;
    ensurePathCapacity(pathLength, pathOffset);
    myWrappedIterator.getName(path, pathOffset);
    pathLen = pathLength;
}

From source file:jetbrains.buildServer.buildTriggers.vcs.git.submodules.SubmoduleAwareTreeIterator.java

License:Apache License

private RevCommit getSubmoduleCommit(@NotNull String path, @NotNull ObjectId entryObjectId)
        throws CorruptObjectException, VcsException, URISyntaxException {
    try {/*from  www. ja v a  2 s. c  om*/
        return mySubmoduleResolver.getSubmoduleCommit(myUrl, path, entryObjectId);
    } catch (VcsAuthenticationException e) {
        //in case of VcsAuthenticationException throw CorruptObjectException without object id,
        //because problem is related to whole repository, not to concrete object
        final SubmoduleFetchException ex = new SubmoduleFetchException(myUrl, path, getPathFromRoot(path));
        ex.initCause(e);
        throw ex;
    } catch (TransportException e) {
        //this problem is also related to whole repository
        final SubmoduleFetchException ex = new SubmoduleFetchException(myUrl, path, getPathFromRoot(path));
        ex.initCause(e);
        throw ex;
    } catch (CorruptObjectException e) {
        throw e;
    } catch (IOException e) {
        final CorruptObjectException ex = new CorruptObjectException(entryObjectId,
                "Commit could not be resolved: " + e.getMessage());
        ex.initCause(e);
        throw ex;
    }
}