Search in sources :

Example 1 with FilePaths

use of com.enonic.xp.repo.impl.dump.FilePaths 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);
        }
    }
}
Also used : FilePaths(com.enonic.xp.repo.impl.dump.FilePaths) DefaultFilePaths(com.enonic.xp.repo.impl.dump.DefaultFilePaths) Branch(com.enonic.xp.branch.Branch) DefaultFilePaths(com.enonic.xp.repo.impl.dump.DefaultFilePaths) IOException(java.io.IOException) RepositoryId(com.enonic.xp.repository.RepositoryId) IOException(java.io.IOException)

Aggregations

Branch (com.enonic.xp.branch.Branch)1 DefaultFilePaths (com.enonic.xp.repo.impl.dump.DefaultFilePaths)1 FilePaths (com.enonic.xp.repo.impl.dump.FilePaths)1 RepositoryId (com.enonic.xp.repository.RepositoryId)1 IOException (java.io.IOException)1