Search in sources :

Example 6 with RepositoryId

use of com.enonic.xp.repository.RepositoryId 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 7 with RepositoryId

use of com.enonic.xp.repository.RepositoryId in project xp by enonic.

the class AbstractMetaDumpUpgrader method deleteBufferFiles.

private void deleteBufferFiles() throws IOException {
    Path bufferFile;
    for (RepositoryId repositoryId : dumpReader.getRepositories()) {
        bufferFile = tmpDumpReader.getVersionsFile(repositoryId);
        Files.deleteIfExists(bufferFile);
        for (Branch branch : dumpReader.getBranches(repositoryId)) {
            bufferFile = tmpDumpReader.getBranchEntriesFile(repositoryId, branch);
            Files.deleteIfExists(bufferFile);
        }
    }
}
Also used : Path(java.nio.file.Path) Branch(com.enonic.xp.branch.Branch) RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 8 with RepositoryId

use of com.enonic.xp.repository.RepositoryId in project xp by enonic.

the class CommitDumpUpgrader method upgradeRepository.

@Override
protected void upgradeRepository(final RepositoryId repositoryId) {
    commitedNodeIds.clear();
    commitedVersionIds.clear();
    processingMaster = true;
    createCommit(repositoryId);
    upgradeBranch(repositoryId, RepositoryConstants.MASTER_BRANCH);
    processingMaster = false;
    if (!commitedNodeIds.isEmpty()) {
        dumpReader.getBranches(repositoryId).stream().filter(branch -> !RepositoryConstants.MASTER_BRANCH.equals(branch)).forEach(branch -> upgradeBranch(repositoryId, branch));
        final Path versionsFile = dumpReader.getVersionsFile(repositoryId);
        if (Files.exists(versionsFile)) {
            upgradeVersionEntries(repositoryId, versionsFile);
        }
    }
}
Also used : AbstractMetaDumpUpgrader(com.enonic.xp.repo.impl.dump.upgrade.AbstractMetaDumpUpgrader) BranchDumpEntryJson(com.enonic.xp.repo.impl.dump.serializer.json.BranchDumpEntryJson) VersionsDumpEntryJson(com.enonic.xp.repo.impl.dump.serializer.json.VersionsDumpEntryJson) Files(java.nio.file.Files) Version(com.enonic.xp.util.Version) Pre6VersionsDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre6.Pre6VersionsDumpEntryJson) NodeCommitId(com.enonic.xp.node.NodeCommitId) VersionDumpEntryJson(com.enonic.xp.repo.impl.dump.serializer.json.VersionDumpEntryJson) Pre6BranchDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre6.Pre6BranchDumpEntryJson) HashSet(java.util.HashSet) NodeCommitEntry(com.enonic.xp.node.NodeCommitEntry) RepositoryId(com.enonic.xp.repository.RepositoryId) Pre6VersionDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre6.Pre6VersionDumpEntryJson) CommitDumpEntryJson(com.enonic.xp.repo.impl.dump.serializer.json.CommitDumpEntryJson) Path(java.nio.file.Path) RepositoryConstants(com.enonic.xp.repository.RepositoryConstants) Path(java.nio.file.Path)

Example 9 with RepositoryId

use of com.enonic.xp.repository.RepositoryId in project xp by enonic.

the class IndexAccessSegmentsDumpUpgrader method upgradeVersionEntry.

@Override
protected byte[] upgradeVersionEntry(final RepositoryId repositoryId, final String entryContent) {
    final Pre4VersionsDumpEntryJson versionsDumpEntry = deserializeValue(entryContent, Pre4VersionsDumpEntryJson.class);
    Collection<Pre6VersionDumpEntryJson> versions = versionsDumpEntry.getVersions().stream().map(versionDumpEntry -> upgradeVersionDumpEntry(repositoryId, versionDumpEntry)).collect(Collectors.toList());
    final Pre6VersionsDumpEntryJson upgradedVersionsDumpEntry = Pre6VersionsDumpEntryJson.create().nodeId(versionsDumpEntry.getNodeId()).versions(versions).build();
    return serialize(upgradedVersionsDumpEntry);
}
Also used : AbstractMetaDumpUpgrader(com.enonic.xp.repo.impl.dump.upgrade.AbstractMetaDumpUpgrader) AccessControlJson(com.enonic.xp.repo.impl.node.json.AccessControlJson) Pre4BranchDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4BranchDumpEntryJson) RepositorySegmentUtils(com.enonic.xp.repository.RepositorySegmentUtils) DumpUpgradeException(com.enonic.xp.repo.impl.dump.upgrade.DumpUpgradeException) Collection(java.util.Collection) Version(com.enonic.xp.util.Version) IOException(java.io.IOException) Segment(com.enonic.xp.blob.Segment) Pre6VersionsDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre6.Pre6VersionsDumpEntryJson) Collectors(java.util.stream.Collectors) BlobKey(com.enonic.xp.blob.BlobKey) StandardCharsets(java.nio.charset.StandardCharsets) Pre6BranchDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre6.Pre6BranchDumpEntryJson) Pre4NodeVersionJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4NodeVersionJson) Pre4VersionDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4VersionDumpEntryJson) RepositoryId(com.enonic.xp.repository.RepositoryId) Pre6VersionDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre6.Pre6VersionDumpEntryJson) Pre4VersionsDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4VersionsDumpEntryJson) DumpBlobRecord(com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord) CharSource(com.google.common.io.CharSource) DumpConstants(com.enonic.xp.repo.impl.dump.DumpConstants) Path(java.nio.file.Path) Pre4VersionsDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre4.Pre4VersionsDumpEntryJson) Pre6VersionDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre6.Pre6VersionDumpEntryJson) Pre6VersionsDumpEntryJson(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre6.Pre6VersionsDumpEntryJson)

Example 10 with RepositoryId

use of com.enonic.xp.repository.RepositoryId in project xp by enonic.

the class MultiRepoSearchSourceAdaptor method createSourceFilters.

private static Filter createSourceFilters(final MultiRepoSearchSource sources) {
    final RepoBranchAclMap repoBranchAclMap = RepoBranchAclMap.from(sources);
    final BooleanFilter.Builder sourceFilters = BooleanFilter.create();
    for (final RepositoryId repoId : repoBranchAclMap) {
        sourceFilters.must(createRepoFilter(repoId, repoBranchAclMap.getBranchAclEntries(repoId)));
    }
    return sourceFilters.build();
}
Also used : BooleanFilter(com.enonic.xp.query.filter.BooleanFilter) RepositoryId(com.enonic.xp.repository.RepositoryId)

Aggregations

RepositoryId (com.enonic.xp.repository.RepositoryId)61 Test (org.junit.jupiter.api.Test)21 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)19 Branch (com.enonic.xp.branch.Branch)14 Repository (com.enonic.xp.repository.Repository)11 Node (com.enonic.xp.node.Node)9 ByteSource (com.google.common.io.ByteSource)8 IOException (java.io.IOException)7 PropertyTree (com.enonic.xp.data.PropertyTree)6 Segment (com.enonic.xp.blob.Segment)5 Context (com.enonic.xp.context.Context)5 ContextAccessor (com.enonic.xp.context.ContextAccessor)5 ContextBuilder (com.enonic.xp.context.ContextBuilder)5 BlobKey (com.enonic.xp.blob.BlobKey)4 EventPublisher (com.enonic.xp.event.EventPublisher)4 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)4 Project (com.enonic.xp.project.Project)4 DumpConstants (com.enonic.xp.repo.impl.dump.DumpConstants)4 DumpBlobRecord (com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord)4 RepositoryIds (com.enonic.xp.repository.RepositoryIds)4