Search in sources :

Example 1 with Repositories

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

the class DumpServiceImplTest method repositories_loaded.

@Test
public void repositories_loaded() throws Exception {
    final Repositories repositoriesBefore = NodeHelper.runAsAdmin(this::doListRepositories);
    NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true));
    final Repositories repositoriesAfter = NodeHelper.runAsAdmin(this::doListRepositories);
    assertEquals(repositoriesBefore.getIds(), repositoriesAfter.getIds());
}
Also used : Repositories(com.enonic.xp.repository.Repositories) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 2 with Repositories

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

the class DumpServiceImplTest method obsolete_repository_deleted.

@Test
public void obsolete_repository_deleted() throws Exception {
    final AccessControlList newRepoACL = AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allowAll().build()).build();
    final Repository newRepoInsideDump = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("new-repo-inside-dump"), newRepoACL, ChildOrder.manualOrder()));
    NodeHelper.runAsAdmin(() -> doDump(SystemDumpParams.create().dumpName("myTestDump").build()));
    final Repository newRepoOutsideDump = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("new-repo-outside-dump"), newRepoACL, ChildOrder.manualOrder()));
    final Repositories oldRepos = NodeHelper.runAsAdmin(this::doListRepositories);
    NodeHelper.runAsAdmin(this::doLoad);
    final Repositories newRepos = NodeHelper.runAsAdmin(this::doListRepositories);
    assertEquals(6, oldRepos.getIds().getSize());
    assertEquals(5, newRepos.getIds().getSize());
    assertNotNull(newRepos.getRepositoryById(newRepoInsideDump.getId()));
    assertNull(newRepos.getRepositoryById(newRepoOutsideDump.getId()));
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) Repositories(com.enonic.xp.repository.Repositories) Repository(com.enonic.xp.repository.Repository) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 3 with Repositories

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

the class DumpServiceImplTest method zip_unzip.

@Test
public void zip_unzip() throws Exception {
    final Node node = createNode(NodePath.ROOT, "myNode");
    updateNode(node);
    updateNode(node);
    updateNode(node);
    refresh();
    final SystemDumpResult systemDumpResult = NodeHelper.runAsAdmin(() -> this.dumpService.dump(SystemDumpParams.create().archive(true).includeVersions(true).dumpName("testDump").build()));
    // 4 of node, 1 of root
    assertEquals(5, systemDumpResult.get(TEST_REPO_ID).getVersions());
    final BranchDumpResult branchDumpResult = systemDumpResult.get(TEST_REPO_ID).get(WS_DEFAULT);
    assertEquals(2, branchDumpResult.getSuccessful());
    NodeHelper.runAsAdmin(() -> this.dumpService.load(SystemLoadParams.create().archive(true).includeVersions(true).dumpName("testDump").build()));
    final Repositories newRepos = NodeHelper.runAsAdmin(this::doListRepositories);
    assertEquals(RepositoryIds.from(RepositoryId.from("com.enonic.cms.test"), RepositoryId.from("system-repo"), RepositoryId.from("system.auditlog"), RepositoryId.from("system.scheduler")), newRepos.getIds());
}
Also used : Repositories(com.enonic.xp.repository.Repositories) BranchDumpResult(com.enonic.xp.dump.BranchDumpResult) Node(com.enonic.xp.node.Node) SystemDumpResult(com.enonic.xp.dump.SystemDumpResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 4 with Repositories

use of com.enonic.xp.repository.Repositories 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)

Aggregations

Repositories (com.enonic.xp.repository.Repositories)4 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)3 Test (org.junit.jupiter.api.Test)3 Repository (com.enonic.xp.repository.Repository)2 Branch (com.enonic.xp.branch.Branch)1 Context (com.enonic.xp.context.Context)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 ContextBuilder (com.enonic.xp.context.ContextBuilder)1 FileNames (com.enonic.xp.core.internal.FileNames)1 BranchDumpResult (com.enonic.xp.dump.BranchDumpResult)1 BranchLoadResult (com.enonic.xp.dump.BranchLoadResult)1 DumpService (com.enonic.xp.dump.DumpService)1 RepoLoadResult (com.enonic.xp.dump.RepoLoadResult)1 SystemDumpResult (com.enonic.xp.dump.SystemDumpResult)1 SystemLoadListener (com.enonic.xp.dump.SystemLoadListener)1 SystemLoadParams (com.enonic.xp.dump.SystemLoadParams)1 SystemLoadResult (com.enonic.xp.dump.SystemLoadResult)1 ExportService (com.enonic.xp.export.ExportService)1 ImportNodesParams (com.enonic.xp.export.ImportNodesParams)1 NodeImportResult (com.enonic.xp.export.NodeImportResult)1