use of com.enonic.xp.repo.impl.dump.RepoLoadException in project xp by enonic.
the class AbstractDumpReader method getBinary.
@Override
public ByteSource getBinary(final RepositoryId repositoryId, final String blobKey) {
final Segment segment = RepositorySegmentUtils.toSegment(repositoryId, DumpConstants.DUMP_BINARY_SEGMENT_LEVEL);
final DumpBlobRecord record = this.dumpBlobStore.getRecord(segment, BlobKey.from(blobKey));
if (record == null) {
throw new RepoLoadException("Cannot find referred blob id " + blobKey + " in dump");
}
return record.getBytes();
}
use of com.enonic.xp.repo.impl.dump.RepoLoadException in project xp by enonic.
the class FileDumpReader method create.
public static FileDumpReader create(final SystemLoadListener listener, Path basePath, final String dumpName, FilePaths filePaths) {
Preconditions.checkArgument(FileNames.isSafeFileName(dumpName));
final Path dumpPath = basePath.resolve(dumpName);
if (!Files.isDirectory(dumpPath)) {
throw new RepoLoadException("Directory is not a valid dump directory: [" + dumpPath + "]");
}
return new FileDumpReader(listener, filePaths, new FileDumpBlobStore(dumpPath), dumpPath);
}
use of com.enonic.xp.repo.impl.dump.RepoLoadException in project xp by enonic.
the class ZipDumpReaderTest method test_archive_without_dumpJson.
@Test
public void test_archive_without_dumpJson() throws Exception {
final Path metaPath = createFolder(dumpFolder, "meta");
final Path repository = createFolder(metaPath, "repository");
createFolder(repository, "master");
createZipArchive(dumpFolder, dumpFolder.getParent().resolve("archive.zip"));
final RepoLoadException exception = assertThrows(RepoLoadException.class, () -> {
try (ZipDumpReader zipDumpReader = ZipDumpReader.create(null, dumpFolder.getParent(), "archive")) {
// do nothing
}
});
assertEquals("Archive is not a valid dump archive: [archive]", exception.getMessage());
}
use of com.enonic.xp.repo.impl.dump.RepoLoadException in project xp by enonic.
the class AbstractEntryProcessor method validateOrAddBinary.
void validateOrAddBinary(final NodeVersion nodeVersion, final EntryLoadResult.Builder result) {
nodeVersion.getAttachedBinaries().forEach(binary -> {
final Segment segment = RepositorySegmentUtils.toSegment(repositoryId, NodeConstants.BINARY_SEGMENT_LEVEL);
final BlobRecord existingRecord = this.blobStore.getRecord(segment, BlobKey.from(binary.getBlobKey()));
if (existingRecord == null) {
try {
final ByteSource dumpBinary = this.dumpReader.getBinary(repositoryId, binary.getBlobKey());
this.blobStore.addRecord(segment, dumpBinary);
} catch (RepoLoadException e) {
reportBinaryError(nodeVersion, result, binary, e);
}
}
});
}
Aggregations