Search in sources :

Example 16 with Repository

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);
}
Also used : ArchiveInitializer(com.enonic.xp.core.impl.project.init.ArchiveInitializer) DeleteRepositoryParams(com.enonic.xp.repository.DeleteRepositoryParams) RepositoryService(com.enonic.xp.repository.RepositoryService) LoggerFactory(org.slf4j.LoggerFactory) AttachmentSerializer(com.enonic.xp.attachment.AttachmentSerializer) ImageHelper(com.enonic.xp.image.ImageHelper) IndexService(com.enonic.xp.index.IndexService) BigDecimal(java.math.BigDecimal) RepositoryId(com.enonic.xp.repository.RepositoryId) ContextAccessor(com.enonic.xp.context.ContextAccessor) NodeService(com.enonic.xp.node.NodeService) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) ImageIO(javax.imageio.ImageIO) ContextBuilder(com.enonic.xp.context.ContextBuilder) EnumSet(java.util.EnumSet) SecurityService(com.enonic.xp.security.SecurityService) RoundingMode(java.math.RoundingMode) BinaryReference(com.enonic.xp.util.BinaryReference) ProjectService(com.enonic.xp.project.ProjectService) Projects(com.enonic.xp.project.Projects) BufferedImage(java.awt.image.BufferedImage) BinaryAttachment(com.enonic.xp.node.BinaryAttachment) Project(com.enonic.xp.project.Project) Collectors(java.util.stream.Collectors) CreateProjectParams(com.enonic.xp.project.CreateProjectParams) UpdateRepositoryParams(com.enonic.xp.repository.UpdateRepositoryParams) UncheckedIOException(java.io.UncheckedIOException) List(java.util.List) ProjectNotFoundException(com.enonic.xp.project.ProjectNotFoundException) Optional(java.util.Optional) RoleKeys(com.enonic.xp.security.RoleKeys) Context(com.enonic.xp.context.Context) Queue(java.util.Queue) Repository(com.enonic.xp.repository.Repository) EventPublisher(com.enonic.xp.event.EventPublisher) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Callable(java.util.concurrent.Callable) Attachment(com.enonic.xp.attachment.Attachment) ProjectConstants(com.enonic.xp.project.ProjectConstants) ProjectGraphEntry(com.enonic.xp.project.ProjectGraphEntry) ArrayList(java.util.ArrayList) IssueInitializer(com.enonic.xp.core.impl.project.init.IssueInitializer) ProjectRole(com.enonic.xp.project.ProjectRole) CreateAttachments(com.enonic.xp.attachment.CreateAttachments) ProjectName(com.enonic.xp.project.ProjectName) ContentInitializer(com.enonic.xp.core.impl.project.init.ContentInitializer) ModifyProjectIconParams(com.enonic.xp.project.ModifyProjectIconParams) ByteSource(com.google.common.io.ByteSource) PropertyTree(com.enonic.xp.data.PropertyTree) Logger(org.slf4j.Logger) ProjectGraph(com.enonic.xp.project.ProjectGraph) ProjectPermissions(com.enonic.xp.project.ProjectPermissions) PropertySet(com.enonic.xp.data.PropertySet) IOException(java.io.IOException) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) ModifyProjectParams(com.enonic.xp.project.ModifyProjectParams) InputStream(java.io.InputStream) Repository(com.enonic.xp.repository.Repository) UpdateRepositoryParams(com.enonic.xp.repository.UpdateRepositoryParams)

Example 17 with Repository

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;
}
Also used : IndexMapping(com.enonic.xp.repository.IndexMapping) Repository(com.enonic.xp.repository.Repository)

Example 18 with Repository

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

the class IndexServiceImpl method getSearchIndexSettings.

private IndexSettings getSearchIndexSettings(final RepositoryId repositoryId) {
    final IndexSettings defaultIndexSettings = DEFAULT_INDEX_RESOURCE_PROVIDER.getSettings(repositoryId, IndexType.SEARCH);
    final Repository repositoryEntry = repositoryEntryService.getRepositoryEntry(repositoryId);
    if (repositoryEntry != null) {
        final IndexSettings indexSettings = repositoryEntry.getSettings().getIndexSettings(IndexType.SEARCH);
        if (indexSettings != null) {
            return new IndexSettings(JsonHelper.merge(defaultIndexSettings.getNode(), indexSettings.getNode()));
        }
    }
    return defaultIndexSettings;
}
Also used : Repository(com.enonic.xp.repository.Repository) IndexSettings(com.enonic.xp.repository.IndexSettings)

Example 19 with Repository

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);
}
Also used : FindNodesByMultiRepoQueryResult(com.enonic.xp.node.FindNodesByMultiRepoQueryResult) Repository(com.enonic.xp.repository.Repository) MultiRepoNodeQuery(com.enonic.xp.node.MultiRepoNodeQuery) NodeQuery(com.enonic.xp.node.NodeQuery) SearchTargets(com.enonic.xp.node.SearchTargets) Test(org.junit.jupiter.api.Test)

Example 20 with Repository

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

the class FindNodesByMultiRepoQueryCommandTest method no_access_in_one_repo_of_three.

@Test
public void no_access_in_one_repo_of_three() throws Exception {
    final Repository repo1 = createRepo(REPO_USER_1, "repo1");
    final Repository repo2 = createRepo(REPO_USER_2, "repo2");
    final Repository repo3 = createRepo(REPO_USER_3, "repo3");
    runInContext(REPO_USER_1, repo1.getId(), () -> createNode(NodePath.ROOT, "repo1Node"));
    runInContext(REPO_USER_2, repo2.getId(), () -> createNode(NodePath.ROOT, "repo2Node"));
    runInContext(REPO_USER_3, repo3.getId(), () -> createNode(NodePath.ROOT, "repo2Node"));
    final SearchTargets targets = SearchTargets.create().add(createTarget(MASTER_BRANCH, REPO_USER_1, repo1.getId())).add(createTarget(MASTER_BRANCH, REPO_USER_2, repo2.getId())).add(// repoUser1 has no access
    createTarget(MASTER_BRANCH, REPO_USER_1, repo3.getId())).build();
    final NodeQuery query = NodeQuery.create().parent(NodePath.ROOT).build();
    final FindNodesByMultiRepoQueryResult result = doQuery(query, targets);
    assertEquals(2L, result.getTotalHits());
    assertRepos(result, repo1.getId(), repo2.getId());
    assertBranches(result, MASTER_BRANCH);
}
Also used : FindNodesByMultiRepoQueryResult(com.enonic.xp.node.FindNodesByMultiRepoQueryResult) Repository(com.enonic.xp.repository.Repository) MultiRepoNodeQuery(com.enonic.xp.node.MultiRepoNodeQuery) NodeQuery(com.enonic.xp.node.NodeQuery) SearchTargets(com.enonic.xp.node.SearchTargets) Test(org.junit.jupiter.api.Test)

Aggregations

Repository (com.enonic.xp.repository.Repository)40 Test (org.junit.jupiter.api.Test)21 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)15 RepositoryId (com.enonic.xp.repository.RepositoryId)10 Node (com.enonic.xp.node.Node)9 Branch (com.enonic.xp.branch.Branch)8 PropertyTree (com.enonic.xp.data.PropertyTree)7 Context (com.enonic.xp.context.Context)6 FindNodesByMultiRepoQueryResult (com.enonic.xp.node.FindNodesByMultiRepoQueryResult)5 MultiRepoNodeQuery (com.enonic.xp.node.MultiRepoNodeQuery)5 NodeQuery (com.enonic.xp.node.NodeQuery)5 SearchTargets (com.enonic.xp.node.SearchTargets)5 ContextAccessor (com.enonic.xp.context.ContextAccessor)4 ContextBuilder (com.enonic.xp.context.ContextBuilder)4 CreateRepositoryParams (com.enonic.xp.repository.CreateRepositoryParams)4 RepositoryService (com.enonic.xp.repository.RepositoryService)4 SystemLoadResult (com.enonic.xp.dump.SystemLoadResult)3 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)3 NodeService (com.enonic.xp.node.NodeService)3 Project (com.enonic.xp.project.Project)3