Search in sources :

Example 1 with RepoLoadException

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();
}
Also used : RepoLoadException(com.enonic.xp.repo.impl.dump.RepoLoadException) DumpBlobRecord(com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord) Segment(com.enonic.xp.blob.Segment)

Example 2 with RepoLoadException

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);
}
Also used : Path(java.nio.file.Path) RepoLoadException(com.enonic.xp.repo.impl.dump.RepoLoadException) FileDumpBlobStore(com.enonic.xp.repo.impl.dump.blobstore.FileDumpBlobStore)

Example 3 with RepoLoadException

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());
}
Also used : Path(java.nio.file.Path) RepoLoadException(com.enonic.xp.repo.impl.dump.RepoLoadException) Test(org.junit.jupiter.api.Test)

Example 4 with RepoLoadException

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);
            }
        }
    });
}
Also used : BlobRecord(com.enonic.xp.blob.BlobRecord) RepoLoadException(com.enonic.xp.repo.impl.dump.RepoLoadException) ByteSource(com.google.common.io.ByteSource) Segment(com.enonic.xp.blob.Segment)

Aggregations

RepoLoadException (com.enonic.xp.repo.impl.dump.RepoLoadException)4 Segment (com.enonic.xp.blob.Segment)2 Path (java.nio.file.Path)2 BlobRecord (com.enonic.xp.blob.BlobRecord)1 DumpBlobRecord (com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord)1 FileDumpBlobStore (com.enonic.xp.repo.impl.dump.blobstore.FileDumpBlobStore)1 ByteSource (com.google.common.io.ByteSource)1 Test (org.junit.jupiter.api.Test)1