Example usage for org.eclipse.jgit.internal.storage.dfs DfsPackDescription getFileName

List of usage examples for org.eclipse.jgit.internal.storage.dfs DfsPackDescription getFileName

Introduction

In this page you can find the example usage for org.eclipse.jgit.internal.storage.dfs DfsPackDescription getFileName.

Prototype

public String getFileName(PackExt ext) 

Source Link

Document

Get file name

Usage

From source file:com.benhumphreys.jgitcassandra.store.ObjStore.java

License:Apache License

/**
 * Returns a ByteBuffer with the contents of the file given by the pair
 * "desc" and "ext"./*from  ww w  .  jav  a2s  .c  o m*/
 *
 * @throws IOException  if an exception occurs when communicating to the
 *                      database
 */
public ByteBuffer readFile(DfsPackDescription desc, PackExt ext) throws IOException {
    try {
        Statement stmt = QueryBuilder.select().all().from(keyspace, DATA_TABLE_NAME)
                .where(QueryBuilder.eq("name", desc.getFileName(ext)));
        ResultSet results = session.execute(stmt);
        Row r = results.one();
        if (!results.isExhausted()) {
            throw new IllegalStateException("Multiple rows for a single file: " + desc.getFileName(ext));
        }
        return r.getBytes("data");
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw new IOException(e);
    }
}

From source file:com.benhumphreys.jgitcassandra.store.ObjStore.java

License:Apache License

/**
 * Overwrites the file given by the pair "desc" and "ext" witht the data in
 * the "data" ByteArray./* w ww . j  a v a  2 s  .co m*/
 *
 * @throws IOException if an exception occurs when communicating to the
 *                     database
 */
public void writeFile(DfsPackDescription desc, PackExt ext, ByteBuffer data) throws IOException {
    try {
        Statement stmt = QueryBuilder.insertInto(keyspace, DATA_TABLE_NAME).value("name", desc.getFileName(ext))
                .value("data", Bytes.toHexString(data));
        session.execute(stmt);
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw new IOException(e);
    }
}

From source file:org.chodavarapu.jgitaws.jgit.S3WithDynamoMetaDataObjDatabase.java

License:Eclipse Distribution License

@Override
protected ReadableChannel openFile(DfsPackDescription desc, PackExt ext) throws IOException {
    logger.debug("Reading pack file {} from S3 bucket", desc.getFileName(ext));
    return configuration.getPackRepository().readPack(desc.getRepositoryDescription().getRepositoryName(),
            desc.getFileName(ext));/*from w w w.jav  a2  s.  c  o m*/
}

From source file:org.chodavarapu.jgitaws.jgit.S3WithDynamoMetaDataObjDatabase.java

License:Eclipse Distribution License

@Override
protected void rollbackPack(Collection<DfsPackDescription> descriptions) {
    if (logger.isDebugEnabled()) {
        if (descriptions != null) {
            for (DfsPackDescription desc : descriptions) {
                StringBuilder files = new StringBuilder();
                for (PackExt ext : PackExt.values()) {
                    if (desc.hasFileExt(ext)) {
                        files.append(desc.getFileName(ext));
                        files.append(", ");
                    }//  w  w w . j  a v a2s.  c o  m
                }
                logger.debug("Rolling back commit of pack files {}due to error", files.toString());
            }
        }
    }
    try {
        configuration.getPackRepository().deletePacks(descriptions).toBlocking().last();
    } catch (Exception e) {
        logger.debug("Error occurred while trying to rollback a pack commit operation!", e);
    }
}

From source file:org.chodavarapu.jgitaws.jgit.S3WithDynamoMetaDataObjDatabase.java

License:Eclipse Distribution License

@Override
protected DfsOutputStream writeFile(DfsPackDescription desc, PackExt ext) throws IOException {
    logger.debug("Writing pack file {} to S3 bucket", desc.getFileName(ext));
    return configuration.getPackRepository().savePack(desc.getRepositoryDescription().getRepositoryName(),
            desc.getFileName(ext), desc.getFileSize(ext));
}

From source file:org.chodavarapu.jgitaws.repositories.PackDescriptionRepository.java

License:Eclipse Distribution License

private String packName(DfsPackDescription desc) {
    String packName = desc.getFileName(PackExt.PACK);
    int packNameSeparatorIx = packName.indexOf('.');
    if (packNameSeparatorIx > 0) {
        packName = packName.substring(0, packNameSeparatorIx);
    }//from www.jav  a 2 s.  c  om

    return packName;
}

From source file:org.chodavarapu.jgitaws.repositories.PackRepository.java

License:Eclipse Distribution License

private List<String> getObjectNames(Collection<DfsPackDescription> packs) {
    List<String> objectNames = new ArrayList<>();
    for (DfsPackDescription pack : packs) {
        for (PackExt ext : PackExt.values()) {
            if (pack.hasFileExt(ext)) {
                objectNames.add(//  ww w .ja v  a2s . c o  m
                        objectName(pack.getRepositoryDescription().getRepositoryName(), pack.getFileName(ext)));
            }
        }
    }

    return objectNames;
}