Search in sources :

Example 21 with Repository

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

the class ProjectServiceImplTest method create_with_data.

@Test
void create_with_data() {
    final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
    final String displayName = "test display name";
    final String description = "test description";
    final PropertyTree data = new PropertyTree();
    final PropertySet projectData = data.addSet(ProjectConstants.PROJECT_DATA_SET_NAME);
    projectData.setString(ProjectConstants.PROJECT_DISPLAY_NAME_PROPERTY, displayName);
    projectData.setString(ProjectConstants.PROJECT_DESCRIPTION_PROPERTY, description);
    adminContext().callWith(() -> doCreateProject(ProjectName.from(projectRepoId), displayName, description));
    adminContext().runWith(() -> {
        final Repository projectRepo = repositoryService.get(projectRepoId);
        assertEquals(data, projectRepo.getData());
    });
}
Also used : Repository(com.enonic.xp.repository.Repository) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) RepositoryId(com.enonic.xp.repository.RepositoryId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 22 with Repository

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 = Mockito.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);
    });
}
Also used : Project(com.enonic.xp.project.Project) Repository(com.enonic.xp.repository.Repository) IndexServiceInternal(com.enonic.xp.repo.impl.index.IndexServiceInternal) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) RepositoryId(com.enonic.xp.repository.RepositoryId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 23 with Repository

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

the class ImportRunnableTask method initializeStoredRepositories.

private void initializeStoredRepositories() {
    this.repositoryService.invalidateAll();
    for (Repository repository : repositoryService.list()) {
        if (!this.nodeRepositoryService.isInitialized(repository.getId())) {
            final CreateRepositoryParams createRepositoryParams = CreateRepositoryParams.create().repositoryId(repository.getId()).repositorySettings(repository.getSettings()).data(repository.getData()).build();
            this.nodeRepositoryService.create(createRepositoryParams);
        }
    }
}
Also used : CreateRepositoryParams(com.enonic.xp.repository.CreateRepositoryParams) Repository(com.enonic.xp.repository.Repository)

Example 24 with Repository

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

the class LoadRunnableTask method doLoadFromExport.

private SystemLoadResultJson doLoadFromExport(final Path rootDir) {
    final SystemLoadResult.Builder builder = SystemLoadResult.create();
    final Repositories repositories = repositoryService.list();
    final long branchesCount = repositories.stream().flatMap(repository -> repository.getBranches().stream()).count();
    loadDumpListener.totalBranches(branchesCount);
    builder.add(importSystemRepo(rootDir));
    this.repositoryService.invalidateAll();
    for (Repository repository : repositories) {
        initializeRepo(repository);
        builder.add(importRepoBranches(rootDir, repository));
    }
    return SystemLoadResultJson.from(builder.build());
}
Also used : Repositories(com.enonic.xp.repository.Repositories) RepositoryService(com.enonic.xp.repository.RepositoryService) VirtualFiles(com.enonic.xp.vfs.VirtualFiles) Branch(com.enonic.xp.branch.Branch) RepoLoadResult(com.enonic.xp.dump.RepoLoadResult) SystemLoadResultJson(com.enonic.xp.impl.server.rest.model.SystemLoadResultJson) AbstractRunnableTask(com.enonic.xp.task.AbstractRunnableTask) RepositoryId(com.enonic.xp.repository.RepositoryId) ContextAccessor(com.enonic.xp.context.ContextAccessor) ImportNodesParams(com.enonic.xp.export.ImportNodesParams) DumpService(com.enonic.xp.dump.DumpService) NodeImportResult(com.enonic.xp.export.NodeImportResult) ContextBuilder(com.enonic.xp.context.ContextBuilder) ProgressReporter(com.enonic.xp.task.ProgressReporter) SystemConstants(com.enonic.xp.security.SystemConstants) Path(java.nio.file.Path) NodeRepositoryService(com.enonic.xp.repository.NodeRepositoryService) Files(java.nio.file.Files) ExportService(com.enonic.xp.export.ExportService) NodeImportResultTranslator(com.enonic.xp.impl.server.rest.NodeImportResultTranslator) NodePath(com.enonic.xp.node.NodePath) SystemLoadListener(com.enonic.xp.dump.SystemLoadListener) CreateRepositoryParams(com.enonic.xp.repository.CreateRepositoryParams) TaskId(com.enonic.xp.task.TaskId) Repositories(com.enonic.xp.repository.Repositories) SystemLoadParams(com.enonic.xp.dump.SystemLoadParams) HomeDir(com.enonic.xp.home.HomeDir) SystemLoadRequestJson(com.enonic.xp.impl.server.rest.model.SystemLoadRequestJson) FileNames(com.enonic.xp.core.internal.FileNames) Preconditions(com.google.common.base.Preconditions) Context(com.enonic.xp.context.Context) SystemLoadListenerImpl(com.enonic.xp.impl.server.rest.task.listener.SystemLoadListenerImpl) BranchLoadResult(com.enonic.xp.dump.BranchLoadResult) SystemLoadResult(com.enonic.xp.dump.SystemLoadResult) Repository(com.enonic.xp.repository.Repository) Repository(com.enonic.xp.repository.Repository) SystemLoadResult(com.enonic.xp.dump.SystemLoadResult)

Example 25 with Repository

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

the class DumpServiceImplTest method dumpAndLoadWithAttachments.

@Test
public void dumpAndLoadWithAttachments() throws Exception {
    NodeHelper.runAsAdmin(() -> {
        final Repository newRepo = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("new-repo"), AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allowAll().build()).build(), ChildOrder.manualOrder()));
        final PropertyTree data = new PropertyTree();
        data.addBinaryReference("attachmentName", BinaryReference.from("image.png"));
        final UpdateRepositoryEntryParams updateParams = UpdateRepositoryEntryParams.create().repositoryId(newRepo.getId()).repositoryData(data).attachments(ImmutableList.of(new BinaryAttachment(BinaryReference.from("image.png"), ByteSource.wrap("attachmentName".getBytes())))).build();
        repositoryEntryService.updateRepositoryEntry(updateParams);
    });
    NodeHelper.runAsAdmin(() -> this.dumpService.dump(SystemDumpParams.create().dumpName("testDump").build()));
    NodeHelper.runAsAdmin(() -> {
        dumpDeleteAndLoad(true);
        final AttachedBinaries attachedBinaries = repositoryEntryService.getRepositoryEntry(RepositoryId.from("new-repo")).getAttachments();
        assertEquals(1, attachedBinaries.getSize());
        assertNotNull(attachedBinaries.getByBinaryReference(BinaryReference.from("image.png")));
    });
}
Also used : Repository(com.enonic.xp.repository.Repository) PropertyTree(com.enonic.xp.data.PropertyTree) AttachedBinaries(com.enonic.xp.node.AttachedBinaries) BinaryAttachment(com.enonic.xp.node.BinaryAttachment) UpdateRepositoryEntryParams(com.enonic.xp.repo.impl.repository.UpdateRepositoryEntryParams) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

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