Example usage for org.apache.commons.compress.archivers.tar TarArchiveEntry setIds

List of usage examples for org.apache.commons.compress.archivers.tar TarArchiveEntry setIds

Introduction

In this page you can find the example usage for org.apache.commons.compress.archivers.tar TarArchiveEntry setIds.

Prototype

public void setIds(int userId, int groupId) 

Source Link

Document

Convenience method to set this entry's group and user ids.

Usage

From source file:cpcc.vvrte.services.VirtualVehicleMigratorImpl.java

/**
 * @param os the output stream to write to.
 * @throws IOException thrown in case of errors.
 *///from  w  w  w.j  a  v a 2  s .  c  o  m
private void writeVirtualVehicleStorageChunk(VirtualVehicle virtualVehicle, ArchiveOutputStream os,
        int chunkNumber, List<VirtualVehicleStorage> storageChunk) throws IOException {
    for (VirtualVehicleStorage se : storageChunk) {
        logger.debug("Writing storage entry '" + se.getName() + "'");

        byte[] content = se.getContentAsByteArray();
        TarArchiveEntry entry = new TarArchiveEntry("storage/" + se.getName());
        entry.setModTime(se.getModificationTime());
        entry.setSize(content.length);
        entry.setIds(se.getId(), chunkNumber);
        entry.setNames("vvrte", "cpcc");

        os.putArchiveEntry(entry);
        os.write(content);
        os.closeArchiveEntry();
    }
}

From source file:org.fabrician.maven.plugins.CompressUtils.java

private static ArchiveEntry createArchiveEntry(ArchiveEntry entry, OutputStream out, String alternateBaseDir)
        throws IOException {
    String substitutedName = substituteAlternateBaseDir(entry, alternateBaseDir);
    if (out instanceof TarArchiveOutputStream) {
        TarArchiveEntry newEntry = new TarArchiveEntry(substitutedName);
        newEntry.setSize(entry.getSize());
        newEntry.setModTime(entry.getLastModifiedDate());

        if (entry instanceof TarArchiveEntry) {
            TarArchiveEntry old = (TarArchiveEntry) entry;
            newEntry.setSize(old.getSize());
            newEntry.setIds(old.getUserId(), old.getGroupId());
            newEntry.setNames(old.getUserName(), old.getGroupName());
        }//ww w. j  ava  2s .c o  m
        return newEntry;
    } else if (entry instanceof ZipArchiveEntry) {
        ZipArchiveEntry old = (ZipArchiveEntry) entry;
        ZipArchiveEntry zip = new ZipArchiveEntry(substitutedName);
        zip.setInternalAttributes(old.getInternalAttributes());
        zip.setExternalAttributes(old.getExternalAttributes());
        zip.setExtraFields(old.getExtraFields(true));
        return zip;
    } else {
        return new ZipArchiveEntry(substitutedName);
    }
}