use of com.enonic.xp.repo.impl.dump.RepoDumpException in project xp by enonic.
the class AbstractDumpReader method doLoadEntries.
private EntriesLoadResult doLoadEntries(final LineProcessor<EntryLoadResult> processor, final PathRef tarFile) {
final EntriesLoadResult.Builder result = EntriesLoadResult.create();
try (TarArchiveInputStream tarInputStream = openStream(tarFile)) {
TarArchiveEntry entry = tarInputStream.getNextTarEntry();
while (entry != null) {
final EntryLoadResult entryLoadResult = handleEntry(processor, tarInputStream);
result.add(entryLoadResult);
entry = tarInputStream.getNextTarEntry();
}
} catch (IOException e) {
throw new RepoDumpException("Cannot read meta-data", e);
}
return result.build();
}
use of com.enonic.xp.repo.impl.dump.RepoDumpException in project xp by enonic.
the class AbstractDumpUpgrader method processEntries.
public void processEntries(final BiConsumer<String, String> processor, final Path tarFile) {
try (TarArchiveInputStream tarInputStream = openStream(tarFile)) {
TarArchiveEntry entry = tarInputStream.getNextTarEntry();
while (entry != null) {
String entryContent = new String(tarInputStream.readAllBytes(), StandardCharsets.UTF_8);
processor.accept(entryContent, entry.getName());
entry = tarInputStream.getNextTarEntry();
}
} catch (IOException e) {
throw new RepoDumpException("Cannot read meta-data", e);
}
}
use of com.enonic.xp.repo.impl.dump.RepoDumpException in project xp by enonic.
the class AbstractDumpWriter method writeBinaryBlob.
@Override
public void writeBinaryBlob(final RepositoryId repositoryId, final BlobKey blobKey) {
final Segment dumpSegment = RepositorySegmentUtils.toSegment(repositoryId, DumpConstants.DUMP_BINARY_SEGMENT_LEVEL);
final BlobRecord binaryRecord = blobStore.getRecord(dumpSegment, blobKey);
if (binaryRecord == null) {
throw new RepoDumpException("Cannot write binary with key [" + blobKey + "], not found in blobStore");
}
final Segment segment = RepositorySegmentUtils.toSegment(repositoryId, NodeConstants.BINARY_SEGMENT_LEVEL);
this.dumpBlobStore.addRecord(segment, binaryRecord.getBytes());
}
use of com.enonic.xp.repo.impl.dump.RepoDumpException in project xp by enonic.
the class AbstractDumpWriter method writeNodeVersionBlobs.
@Override
public void writeNodeVersionBlobs(final RepositoryId repositoryId, final NodeVersionKey nodeVersionKey) {
final Segment nodeDumpSegment = RepositorySegmentUtils.toSegment(repositoryId, DumpConstants.DUMP_NODE_SEGMENT_LEVEL);
final BlobRecord existingNodeBlobRecord = blobStore.getRecord(nodeDumpSegment, nodeVersionKey.getNodeBlobKey());
if (existingNodeBlobRecord == null) {
throw new RepoDumpException("Cannot write node blob with key [" + nodeVersionKey.getNodeBlobKey() + "], not found in blobStore");
}
final Segment indexConfigDumpSegment = RepositorySegmentUtils.toSegment(repositoryId, DumpConstants.DUMP_INDEX_CONFIG_SEGMENT_LEVEL);
final BlobRecord existingIndexConfigBlobRecord = blobStore.getRecord(indexConfigDumpSegment, nodeVersionKey.getIndexConfigBlobKey());
if (existingIndexConfigBlobRecord == null) {
throw new RepoDumpException("Cannot write index config blob with key [" + nodeVersionKey.getIndexConfigBlobKey() + "], not found in blobStore");
}
final Segment accessControlDumpSegment = RepositorySegmentUtils.toSegment(repositoryId, DumpConstants.DUMP_ACCESS_CONTROL_SEGMENT_LEVEL);
final BlobRecord existingAccessControlBlobRecord = blobStore.getRecord(accessControlDumpSegment, nodeVersionKey.getAccessControlBlobKey());
if (existingAccessControlBlobRecord == null) {
throw new RepoDumpException("Cannot write access control blob with key [" + nodeVersionKey.getAccessControlBlobKey() + "], not found in blobStore");
}
final Segment nodeSegment = RepositorySegmentUtils.toSegment(repositoryId, NodeConstants.NODE_SEGMENT_LEVEL);
this.dumpBlobStore.addRecord(nodeSegment, existingNodeBlobRecord.getBytes());
final Segment indexConfigSegment = RepositorySegmentUtils.toSegment(repositoryId, NodeConstants.INDEX_CONFIG_SEGMENT_LEVEL);
this.dumpBlobStore.addRecord(indexConfigSegment, existingIndexConfigBlobRecord.getBytes());
final Segment accessControlSegment = RepositorySegmentUtils.toSegment(repositoryId, NodeConstants.ACCESS_CONTROL_SEGMENT_LEVEL);
this.dumpBlobStore.addRecord(accessControlSegment, existingAccessControlBlobRecord.getBytes());
}
use of com.enonic.xp.repo.impl.dump.RepoDumpException in project xp by enonic.
the class AbstractDumpWriter method openTarStream.
private void openTarStream(final PathRef metaPath) {
try {
this.tarOutputStream = new TarArchiveOutputStream(new GZIPOutputStream(openMetaFileStream(metaPath)));
this.tarOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
} catch (Exception e) {
throw new RepoDumpException("Could not open meta-file", e);
}
}
Aggregations