use of com.enonic.xp.repository.Repository in project xp by enonic.
the class ProjectServiceImplTest method create_in_non_master_node.
@Test
void create_in_non_master_node() {
IndexServiceInternal indexServiceInternalMock = mock(IndexServiceInternal.class);
when(indexServiceInternalMock.waitForYellowStatus()).thenReturn(true);
indexService.setIndexServiceInternal(indexServiceInternalMock);
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final Project project = adminContext().callWith(() -> doCreateProject(ProjectName.from(projectRepoId), null, true, null));
assertNotNull(project);
assertEquals("test-project", project.getName().toString());
final NodeBranchEntry nodeBranchEntry = this.branchService.get(Node.ROOT_UUID, InternalContext.create(adminContext()).repositoryId(projectRepoId).build());
assertNotNull(nodeBranchEntry);
adminContext().runWith(() -> {
final Repository pro = repositoryService.get(projectRepoId);
assertNotNull(pro);
});
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class ProjectServiceImpl method doModify.
private Project doModify(final ModifyProjectParams params) {
final UpdateRepositoryParams updateParams = UpdateRepositoryParams.create().repositoryId(params.getName().getRepoId()).editor(editableRepository -> modifyProjectData(params, editableRepository.data)).build();
final Repository updatedRepository = repositoryService.updateRepository(updateParams);
if (!ProjectConstants.DEFAULT_PROJECT_NAME.equals(params.getName())) {
UpdateProjectRoleNamesCommand.create().securityService(securityService).projectName(params.getName()).projectDisplayName(params.getDisplayName()).build().execute();
}
return Project.from(updatedRepository);
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class IndexServiceImpl method getSearchIndexMapping.
private IndexMapping getSearchIndexMapping(final RepositoryId repositoryId) {
final IndexMapping defaultIndexMapping = DEFAULT_INDEX_RESOURCE_PROVIDER.getMapping(repositoryId, IndexType.SEARCH);
final Repository repositoryEntry = repositoryEntryService.getRepositoryEntry(repositoryId);
if (repositoryEntry != null) {
final IndexMapping indexMapping = repositoryEntry.getSettings().getIndexMappings(IndexType.SEARCH);
if (indexMapping != null) {
return new IndexMapping(JsonHelper.merge(defaultIndexMapping.getNode(), indexMapping.getNode()));
}
}
return defaultIndexMapping;
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class NodeServiceImpl method verifyBranchExists.
private void verifyBranchExists(Branch branch) {
NodeHelper.runAsAdmin(() -> {
final RepositoryId repoId = ContextAccessor.current().getRepositoryId();
final Repository repository = this.repositoryService.get(repoId);
if (repository == null) {
throw new RepositoryNotFoundException(repoId);
}
if (!repository.getBranches().contains(branch)) {
throw new BranchNotFoundException(branch);
}
});
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class FindNodesByMultiRepoQueryCommandTest method no_access_in_one_repo.
@Test
public void no_access_in_one_repo() throws Exception {
final Repository repo1 = createRepo(REPO_USER_1, "repo1");
final Repository repo2 = createRepo(REPO_USER_2, "repo2");
runInContext(REPO_USER_1, repo1.getId(), () -> createNode(NodePath.ROOT, "repo1Node"));
runInContext(REPO_USER_2, repo2.getId(), () -> createNode(NodePath.ROOT, "repo2Node"));
final SearchTargets targets = SearchTargets.create().add(createTarget(MASTER_BRANCH, REPO_USER_1, repo1.getId())).add(// repoUser2 has no access
createTarget(MASTER_BRANCH, REPO_USER_1, repo2.getId())).build();
final NodeQuery query = NodeQuery.create().parent(NodePath.ROOT).build();
final FindNodesByMultiRepoQueryResult result = doQuery(query, targets);
assertEquals(1L, result.getTotalHits());
assertRepos(result, repo1.getId());
assertBranches(result, MASTER_BRANCH);
}
Aggregations