Search in sources :

Example 1 with VersionsLoadResult

use of com.enonic.xp.dump.VersionsLoadResult in project xp by enonic.

the class AbstractDumpReader method loadVersions.

@Override
public VersionsLoadResult loadVersions(final RepositoryId repositoryId, final LineProcessor<EntryLoadResult> processor) {
    final PathRef tarFile = filePaths.versionMetaPath(repositoryId);
    listener.loadingVersions(repositoryId);
    final VersionsLoadResult.Builder builder = VersionsLoadResult.create();
    if (!exists(tarFile)) {
        return builder.build();
    }
    final EntriesLoadResult result = doLoadEntries(processor, tarFile);
    return builder.successful(result.getSuccessful()).errors(result.getErrors().stream().map(error -> LoadError.error(error.getMessage())).collect(Collectors.toList())).build();
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) DumpBlobStore(com.enonic.xp.repo.impl.dump.blobstore.DumpBlobStore) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) FilePaths(com.enonic.xp.repo.impl.dump.FilePaths) RepositoryIds(com.enonic.xp.repository.RepositoryIds) BranchDumpResult(com.enonic.xp.dump.BranchDumpResult) Segment(com.enonic.xp.blob.Segment) BlobKey(com.enonic.xp.blob.BlobKey) Branch(com.enonic.xp.branch.Branch) RepoLoadException(com.enonic.xp.repo.impl.dump.RepoLoadException) RepositoryId(com.enonic.xp.repository.RepositoryId) TarArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry) RepoDumpResult(com.enonic.xp.dump.RepoDumpResult) DumpMetaJsonSerializer(com.enonic.xp.repo.impl.dump.serializer.json.DumpMetaJsonSerializer) ByteSource(com.google.common.io.ByteSource) DumpConstants(com.enonic.xp.repo.impl.dump.DumpConstants) CommitsLoadResult(com.enonic.xp.dump.CommitsLoadResult) ImmutableSet(com.google.common.collect.ImmutableSet) RepositorySegmentUtils(com.enonic.xp.repository.RepositorySegmentUtils) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) IOException(java.io.IOException) SystemLoadListener(com.enonic.xp.dump.SystemLoadListener) Branches(com.enonic.xp.branch.Branches) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) UncheckedIOException(java.io.UncheckedIOException) Objects(java.util.Objects) LineProcessor(com.google.common.io.LineProcessor) SystemDumpResult(com.enonic.xp.dump.SystemDumpResult) LoadError(com.enonic.xp.dump.LoadError) Stream(java.util.stream.Stream) DumpMeta(com.enonic.xp.repo.impl.dump.model.DumpMeta) NodeVersion(com.enonic.xp.node.NodeVersion) VersionsLoadResult(com.enonic.xp.dump.VersionsLoadResult) PathRef(com.enonic.xp.repo.impl.dump.PathRef) DumpBlobRecord(com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord) NullSystemLoadListener(com.enonic.xp.repo.impl.dump.NullSystemLoadListener) BranchLoadResult(com.enonic.xp.dump.BranchLoadResult) RepoDumpException(com.enonic.xp.repo.impl.dump.RepoDumpException) InputStream(java.io.InputStream) PathRef(com.enonic.xp.repo.impl.dump.PathRef) VersionsLoadResult(com.enonic.xp.dump.VersionsLoadResult)

Example 2 with VersionsLoadResult

use of com.enonic.xp.dump.VersionsLoadResult in project xp by enonic.

the class DumpServiceImplTest method number_of_versions_in_other_repo.

@Test
public void number_of_versions_in_other_repo() {
    final Repository myRepo = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("myrepo"), AccessControlList.create().add(AccessControlEntry.create().principal(ctxDefault().getAuthInfo().getUser().getKey()).allowAll().build()).build(), null));
    final Context myRepoContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(myRepo.getId()).branch(RepositoryConstants.MASTER_BRANCH).build();
    final Node myNode = myRepoContext.callWith(() -> createNode(NodePath.ROOT, "myNode"));
    myRepoContext.runWith(() -> updateNode(myNode));
    myRepoContext.runWith(() -> updateNode(myNode));
    myRepoContext.runWith(() -> updateNode(myNode));
    final SystemLoadResult dumpResult = NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true, SystemDumpParams.create().dumpName("myTestDump").build()));
    final RepoLoadResult repoLoadResult = getRepoLoadResult(dumpResult, myRepo.getId());
    final VersionsLoadResult versionsLoadResult = repoLoadResult.getVersionsLoadResult();
    assertNotNull(versionsLoadResult);
    // One for root, 4 for myNode
    assertEquals(5, versionsLoadResult.getSuccessful());
}
Also used : BundleContext(org.osgi.framework.BundleContext) Context(com.enonic.xp.context.Context) InternalContext(com.enonic.xp.repo.impl.InternalContext) Repository(com.enonic.xp.repository.Repository) SystemLoadResult(com.enonic.xp.dump.SystemLoadResult) Node(com.enonic.xp.node.Node) VersionsLoadResult(com.enonic.xp.dump.VersionsLoadResult) RepoLoadResult(com.enonic.xp.dump.RepoLoadResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

VersionsLoadResult (com.enonic.xp.dump.VersionsLoadResult)2 BlobKey (com.enonic.xp.blob.BlobKey)1 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)1 Segment (com.enonic.xp.blob.Segment)1 Branch (com.enonic.xp.branch.Branch)1 Branches (com.enonic.xp.branch.Branches)1 Context (com.enonic.xp.context.Context)1 BranchDumpResult (com.enonic.xp.dump.BranchDumpResult)1 BranchLoadResult (com.enonic.xp.dump.BranchLoadResult)1 CommitsLoadResult (com.enonic.xp.dump.CommitsLoadResult)1 LoadError (com.enonic.xp.dump.LoadError)1 RepoDumpResult (com.enonic.xp.dump.RepoDumpResult)1 RepoLoadResult (com.enonic.xp.dump.RepoLoadResult)1 SystemDumpResult (com.enonic.xp.dump.SystemDumpResult)1 SystemLoadListener (com.enonic.xp.dump.SystemLoadListener)1 SystemLoadResult (com.enonic.xp.dump.SystemLoadResult)1 Node (com.enonic.xp.node.Node)1 NodeVersion (com.enonic.xp.node.NodeVersion)1 InternalContext (com.enonic.xp.repo.impl.InternalContext)1 DumpConstants (com.enonic.xp.repo.impl.dump.DumpConstants)1