use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepoDumper method dumpBranch.
private void dumpBranch(Consumer<NodeId> nodeIdsAccumulator) {
this.nodeService.refresh(RefreshMode.ALL);
final Branch branch = ContextAccessor.current().getBranch();
final BranchDumpResult.Builder branchDumpResult = BranchDumpResult.create(branch);
writer.openBranchMeta(repository.getId(), branch);
try {
dumpBranch(branchDumpResult, nodeIdsAccumulator);
this.dumpResult.add(branchDumpResult.build());
} catch (Exception e) {
throw new RepoDumpException("Error occurred when dumping repository " + repository.getId(), e);
} finally {
writer.closeMeta();
}
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepoDumper method execute.
public RepoDumpResult execute() {
final Set<NodeId> dumpedNodes = new HashSet<>();
final Consumer<NodeId> nodeIdsAccumulator = includeVersions ? dumpedNodes::add : nodeId -> {
};
for (Branch branch : this.repository.getBranches()) {
setContext(branch).runWith(() -> dumpBranch(nodeIdsAccumulator));
}
if (includeVersions) {
setContext(RepositoryConstants.MASTER_BRANCH).runWith(() -> dumpVersions(dumpedNodes));
}
setContext(RepositoryConstants.MASTER_BRANCH).runWith(this::dumpCommits);
return this.dumpResult.build();
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class AbstractDumpReader method loadBranch.
@Override
public BranchLoadResult loadBranch(final RepositoryId repositoryId, final Branch branch, final LineProcessor<EntryLoadResult> processor) {
final PathRef tarFile = filePaths.branchMetaPath(repositoryId, branch);
listener.loadingBranch(repositoryId, branch, getBranchSuccessfulCountFromMeta(repositoryId, branch));
final BranchLoadResult.Builder builder = BranchLoadResult.create(branch);
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();
}
use of com.enonic.xp.branch.Branch 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);
}
}
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class AbstractNodeEventHandler method createNodeContext.
InternalContext createNodeContext(final Map<Object, Object> map, final InternalContext context) {
final InternalContext.Builder nodeContext = InternalContext.create(context);
final RepositoryId repositoryId = getRepositoryId(map);
if (repositoryId != null) {
nodeContext.repositoryId(repositoryId);
}
final Branch branch = getBranch(map);
if (branch != null) {
nodeContext.branch(branch);
}
return nodeContext.build();
}
Aggregations