Example usage for org.eclipse.jgit.lib Constants OBJ_BLOB

List of usage examples for org.eclipse.jgit.lib Constants OBJ_BLOB

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants OBJ_BLOB.

Prototype

int OBJ_BLOB

To view the source code for org.eclipse.jgit.lib Constants OBJ_BLOB.

Click Source Link

Document

In-pack object type: blob.

Usage

From source file:org.webcat.core.git.http.GitBasePage.java

License:Open Source License

public String sourceMenuURL() {
    GitWebContext newContext = gitContext().clone();
    newContext.setMode((newContext.repository().typeOfObject(newContext.objectId()) == Constants.OBJ_BLOB)
            ? GitWebMode.BLOB/* w ww . ja va 2 s.c o m*/
            : GitWebMode.TREE);
    return newContext.toURL(context());
}

From source file:svnserver.repository.git.cache.CacheHelper.java

License:GNU General Public License

@NotNull
public static ObjectId save(@NotNull ObjectInserter inserter, @NotNull CacheRevision cache) throws IOException {
    try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
        save(stream, cache);//from  w  w w .j  a v  a 2  s. c o  m
        return inserter.insert(Constants.OBJ_BLOB, stream.toByteArray());
    }
}

From source file:svnserver.repository.git.filter.GitFilterLink.java

License:GNU General Public License

@Override
public long getSize(@NotNull GitObject<? extends ObjectId> objectId) throws IOException, SVNException {
    final ObjectReader reader = objectId.getRepo().newObjectReader();
    return reader.getObjectSize(objectId.getObject(), Constants.OBJ_BLOB) + LINK_PREFIX.length;
}

From source file:svnserver.repository.git.filter.GitFilterRaw.java

License:GNU General Public License

@Override
public long getSize(@NotNull GitObject<? extends ObjectId> objectId) throws IOException, SVNException {
    final ObjectReader reader = objectId.getRepo().newObjectReader();
    return reader.getObjectSize(objectId.getObject(), Constants.OBJ_BLOB);
}

From source file:svnserver.repository.git.GitCreateMode.java

License:GNU General Public License

@NotNull
private static AnyObjectId insertFile(@NotNull ObjectInserter inserter, @NotNull String resourceName)
        throws IOException {
    final InputStream stream = GitCreateMode.class.getResourceAsStream(resourceName);
    if (stream == null) {
        throw new FileNotFoundException(resourceName);
    }/*w  w w  .  ja  v a2  s .  com*/
    return inserter.insert(Constants.OBJ_BLOB, ByteStreams.toByteArray(stream));
}

From source file:svnserver.repository.git.GitDeltaConsumer.java

License:GNU General Public License

public boolean migrateFilter(@NotNull GitFilter filter) throws IOException, SVNException {
    if (newFilter == null || objectId == null) {
        throw new IllegalStateException("Original object ID defined, but original Filter is not defined");
    }//from  ww  w  .  j av  a2s. c  o  m
    final GitObject<ObjectId> beforeId = objectId;
    if (!newFilter.equals(filter)) {
        final Repository repo = writer.getRepository().getRepository();

        try (final TemporaryOutputStream content = new TemporaryOutputStream();
                final TemporaryOutputStream.Holder holder = content.holder()) {
            try (InputStream inputStream = newFilter.inputStream(objectId);
                    OutputStream outputStream = filter.outputStream(content, user)) {
                ByteStreams.copy(inputStream, outputStream);
            }
            try (InputStream inputStream = content.toInputStream()) {
                objectId = new GitObject<>(repo,
                        writer.getInserter().insert(Constants.OBJ_BLOB, content.size(), inputStream));
                newFilter = filter;
            }
        }
    }
    return !beforeId.equals(objectId);
}

From source file:svnserver.repository.git.GitDeltaConsumer.java

License:GNU General Public License

@Override
public void textDeltaEnd(String path) throws SVNException {
    try (TemporaryOutputStream.Holder holder = temporaryStream.holder()) {
        if (window == null)
            throw new SVNException(SVNErrorMessage.create(SVNErrorCode.RA_SVN_CMD_ERR));

        final Repository repo = writer.getRepository().getRepository();
        md5 = window.textDeltaEnd();/*from  w w w .  ja v  a  2  s .c  o  m*/
        try (InputStream stream = temporaryStream.toInputStream()) {
            objectId = new GitObject<>(repo,
                    writer.getInserter().insert(Constants.OBJ_BLOB, temporaryStream.size(), stream));
        }
        log.info("Created blob {} for file: {}", objectId.getObject().getName(), path);
    } catch (IOException e) {
        throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR), e);
    }
}

From source file:svnserver.repository.git.GitFile.java

License:GNU General Public License

@NotNull
@Override//  w w w.j  av a2 s.  co m
default SVNNodeKind getKind() {
    final int objType = getFileMode().getObjectType();
    switch (objType) {
    case Constants.OBJ_TREE:
    case Constants.OBJ_COMMIT:
        return SVNNodeKind.DIR;
    case Constants.OBJ_BLOB:
        return SVNNodeKind.FILE;
    default:
        throw new IllegalStateException("Unknown obj type: " + objType);
    }
}

From source file:svnserver.repository.git.GitFileTreeEntry.java

License:GNU General Public License

@NotNull
@Override/*  w w w  . ja va  2 s.co  m*/
public Map<String, String> getProperties() throws IOException, SVNException {
    final Map<String, String> props = getUpstreamProperties();
    final FileMode fileMode = getFileMode();
    if (fileMode.equals(FileMode.SYMLINK)) {
        props.remove(SVNProperty.EOL_STYLE);
        props.remove(SVNProperty.MIME_TYPE);
        props.put(SVNProperty.SPECIAL, "*");
    } else {
        if (fileMode.equals(FileMode.EXECUTABLE_FILE)) {
            props.put(SVNProperty.EXECUTABLE, "*");
        }
        if (fileMode.getObjectType() == Constants.OBJ_BLOB && repo.isObjectBinary(filter, getObjectId())) {
            props.remove(SVNProperty.EOL_STYLE);
            props.put(SVNProperty.MIME_TYPE, SVNFileUtil.BINARY_MIME_TYPE);
        }
    }
    return props;
}

From source file:svnserver.repository.git.GitRepository.java

License:GNU General Public License

@NotNull
public GitProperty[] collectProperties(@NotNull GitTreeEntry treeEntry,
        @NotNull VcsSupplier<Iterable<GitTreeEntry>> entryProvider) throws IOException, SVNException {
    if (treeEntry.getFileMode().getObjectType() == Constants.OBJ_BLOB)
        return GitProperty.emptyArray;

    GitProperty[] props = directoryPropertyCache.get(treeEntry.getObjectId().getObject());
    if (props == null) {
        final List<GitProperty> propList = new ArrayList<>();
        try {/*from   w w  w .  ja v  a2s . com*/
            for (GitTreeEntry entry : entryProvider.get()) {
                final GitProperty[] parseProps = parseGitProperty(entry.getFileName(), entry.getObjectId());
                if (parseProps.length > 0) {
                    propList.addAll(Arrays.asList(parseProps));
                }
            }
        } catch (SvnForbiddenException ignored) {
        }
        if (!propList.isEmpty()) {
            props = propList.toArray(new GitProperty[propList.size()]);
        } else {
            props = GitProperty.emptyArray;
        }
        directoryPropertyCache.put(treeEntry.getObjectId().getObject(), props);
    }
    return props;
}