use of com.enonic.xp.repo.impl.dump.DefaultFilePaths in project xp by enonic.
the class AbstractMetaDumpUpgrader method doUpgrade.
@Override
public void doUpgrade(final String dumpName) {
super.doUpgrade(dumpName);
final String timeMillis = Long.toString(System.currentTimeMillis());
FilePaths tmpFilePaths = new DefaultFilePaths() {
@Override
public PathRef branchMetaPath(final RepositoryId repositoryId, final Branch branch) {
return branchRootPath(repositoryId).resolve(branch.toString()).resolve("meta-" + timeMillis + ".tar.gz");
}
@Override
public PathRef versionMetaPath(final RepositoryId repositoryId) {
return branchRootPath(repositoryId).resolve("versions-" + timeMillis + ".tar.gz");
}
};
tmpDumpReader = FileDumpReader.create(null, basePath, dumpName, tmpFilePaths);
tmpDumpWriter = FileDumpWriter.create(basePath, dumpName, null, tmpFilePaths);
try {
dumpReader.getRepositories().forEach(this::upgradeRepository);
overwriteSourceFiles();
} catch (Exception e) {
try {
deleteBufferFiles();
} catch (Exception e2) {
LOG.error("Error while deleting buffer files", e);
}
throw new DumpUpgradeException("Error while upgrading dump [" + dumpName + "]", e);
} finally {
try {
tmpDumpReader.close();
tmpDumpWriter.close();
} catch (IOException e) {
LOG.error("Error while closing dump writer", e);
}
}
}
use of com.enonic.xp.repo.impl.dump.DefaultFilePaths in project xp by enonic.
the class ZipDumpWriter method create.
public static ZipDumpWriter create(final Path basePath, final String dumpName, final BlobStore blobStore) {
Preconditions.checkArgument(FileNames.isSafeFileName(dumpName));
try {
final ZipArchiveOutputStream zipArchiveOutputStream = new ZipArchiveOutputStream(Files.newByteChannel(basePath.resolve(dumpName + ZIP_FILE_EXTENSION), StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.READ, StandardOpenOption.TRUNCATE_EXISTING));
final ZipDumpWriteBlobStore zipDumpWriteBlobStore = new ZipDumpWriteBlobStore(dumpName, zipArchiveOutputStream);
return new ZipDumpWriter(blobStore, new DefaultFilePaths(PathRef.of(dumpName)), zipDumpWriteBlobStore, zipArchiveOutputStream);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
Aggregations