use of com.enonic.xp.branch.Branch in project xp by enonic.
the class GetActiveNodeVersionsCommand method execute.
public GetActiveNodeVersionsResult execute() {
final GetActiveNodeVersionsResult.Builder builder = GetActiveNodeVersionsResult.create();
for (final Branch branch : branches) {
final Context context = ContextAccessor.current();
final NodeBranchEntry nodeBranchEntry = this.nodeStorageService.getBranchNodeVersion(this.nodeId, InternalContext.create(context).branch(branch).build());
if (nodeBranchEntry != null) {
builder.add(branch, this.nodeStorageService.getVersion(nodeBranchEntry.getNodeId(), nodeBranchEntry.getVersionId(), InternalContext.from(context)));
}
}
return builder.build();
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepositoryServiceImpl method doDeleteBranch.
private Repository doDeleteBranch(final DeleteBranchParams params, final RepositoryId repositoryId, Repository previousRepository) {
// If the repository entry does not exist, throws an exception
previousRepository = previousRepository == null ? repositoryEntryService.getRepositoryEntry(repositoryId) : previousRepository;
if (previousRepository == null) {
throw new RepositoryNotFoundException(repositoryId);
}
// If the branch does not exist, throws an exception
final Branch branch = params.getBranch();
if (!previousRepository.getBranches().contains(branch)) {
throw new BranchNotFoundException(branch);
}
// If the root node exists, deletes it
if (getRootNode(previousRepository.getId(), branch) != null) {
deleteRootNode(branch);
}
// Updates the repository entry
return repositoryEntryService.removeBranchFromRepositoryEntry(repositoryId, branch);
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class DumpServiceImplTest method branch_created_if_missing.
@Test
public void branch_created_if_missing() throws Exception {
final Node node = createNode(NodePath.ROOT, "myNode");
final Branch branch = WS_DEFAULT;
final RepositoryId currentRepoId = TEST_REPO_ID;
NodeHelper.runAsAdmin(() -> {
doDump(SystemDumpParams.create().dumpName("testDump").build());
this.repositoryEntryService.removeBranchFromRepositoryEntry(currentRepoId, branch);
assertFalse(this.repositoryEntryService.getRepositoryEntry(currentRepoId).getBranches().contains(branch));
this.dumpService.load(SystemLoadParams.create().dumpName("testDump").build());
assertTrue(this.repositoryEntryService.getRepositoryEntry(currentRepoId).getBranches().contains(branch));
assertNotNull(this.nodeService.getById(node.id()));
});
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class SegmentVacuumTaskTest method setUp.
@BeforeEach
public void setUp() throws Exception {
this.blobStore = new MemoryBlobStore();
this.repositoryId = RepositoryId.from("test");
this.repositoryId2 = RepositoryId.from("test2");
this.segment = RepositorySegmentUtils.toSegment(repositoryId, NodeConstants.NODE_SEGMENT_LEVEL);
this.segment2 = RepositorySegmentUtils.toSegment(repositoryId2, NodeConstants.NODE_SEGMENT_LEVEL);
this.repositoryService = Mockito.mock(RepositoryService.class);
final Branch branch = Branch.from("master");
final Repository repository = Repository.create().id(repositoryId).branches(branch).build();
final Repository repository2 = Repository.create().id(repositoryId).branches(branch).build();
Mockito.when(repositoryService.list()).thenReturn(Repositories.from(repository, repository2));
this.nodeService = Mockito.mock(NodeService.class);
Mockito.when(nodeService.findVersions(Mockito.any(NodeVersionQuery.class))).thenReturn(NodeVersionQueryResult.empty(0));
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepositoryServiceImplTest method create_branch_with_node_in_root.
@Test
void create_branch_with_node_in_root() {
doCreateRepo("fisk");
Branch branch = Branch.from("myBranch");
final var mockCurrentContext = ContextBuilder.create().branch("myBranch").repositoryId("fisk").authInfo(REPO_TEST_DEFAULT_USER_AUTHINFO).build();
mockCurrentContext.callWith(() -> repositoryService.createBranch(CreateBranchParams.from(branch)));
assertDoesNotThrow(() -> mockCurrentContext.callWith(() -> nodeService.create(CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).data(new PropertyTree()).build())));
}
Aggregations