Search in sources :

Example 46 with RepositoryId

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

the class RepositoryServiceImpl method deleteBranch.

@Override
public Branch deleteBranch(final DeleteBranchParams params) {
    requireAdminRole();
    final RepositoryId repositoryId = ContextAccessor.current().getRepositoryId();
    repositoryMap.compute(repositoryId, (key, previousRepository) -> doDeleteBranch(params, repositoryId, previousRepository));
    invalidatePathCache();
    return params.getBranch();
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 47 with RepositoryId

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

the class RepositoryServiceImpl method deleteRepository.

@Override
public RepositoryId deleteRepository(final DeleteRepositoryParams params) {
    requireAdminRole();
    final RepositoryId repositoryId = params.getRepositoryId();
    repositoryMap.compute(repositoryId, (key, previousRepository) -> {
        repositoryEntryService.deleteRepositoryEntry(repositoryId);
        nodeRepositoryService.delete(repositoryId);
        return null;
    });
    invalidatePathCache();
    return repositoryId;
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 48 with RepositoryId

use of com.enonic.xp.repository.RepositoryId 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()));
    });
}
Also used : Branch(com.enonic.xp.branch.Branch) Node(com.enonic.xp.node.Node) RepositoryId(com.enonic.xp.repository.RepositoryId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 49 with RepositoryId

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

the class SnapshotServiceImplTest method restore_all.

@Test
public void restore_all() {
    NodeHelper.runAsAdmin(() -> {
        final RepositoryId newRepoId = RepositoryId.from("new-repo");
        this.repositoryService.createRepository(CreateRepositoryParams.create().repositoryId(newRepoId).build());
        assertNotNull(this.repositoryService.get(newRepoId));
        this.snapshotService.snapshot(SnapshotParams.create().snapshotName("my-snapshot").build());
        this.repositoryService.deleteRepository(DeleteRepositoryParams.from(newRepoId));
        assertNull(this.repositoryService.get(newRepoId));
        this.snapshotService.restore(RestoreParams.create().snapshotName("my-snapshot").build());
        assertTrue(this.repositoryService.isInitialized(newRepoId));
        assertTrue(this.repositoryService.isInitialized(SystemConstants.SYSTEM_REPO_ID));
        assertTrue(this.repositoryService.isInitialized(TEST_REPO_ID));
    });
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 50 with RepositoryId

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

the class SnapshotServiceImplTest method doRestoreLatest.

private void doRestoreLatest() {
    final RepositoryId newRepoId = RepositoryId.from("new-repo");
    this.repositoryService.createRepository(CreateRepositoryParams.create().repositoryId(newRepoId).build());
    assertNotNull(this.repositoryService.get(newRepoId));
    this.snapshotService.snapshot(SnapshotParams.create().snapshotName("my-snapshot-latest").build());
    this.repositoryService.deleteRepository(DeleteRepositoryParams.from(newRepoId));
    assertNull(this.repositoryService.get(newRepoId));
    final RestoreResult restoreResult = this.snapshotService.restore(RestoreParams.create().repositoryId(newRepoId).latest(true).build());
    assertEquals("my-snapshot-latest", restoreResult.getName());
    // The system repo does not know about this repo now
    assertNull(this.repositoryService.get(newRepoId));
    this.snapshotService.restore(RestoreParams.create().repositoryId(SystemConstants.SYSTEM_REPO_ID).snapshotName("my-snapshot-latest").build());
    assertNotNull(this.repositoryService.get(newRepoId));
    assertNotNull(this.repositoryService.get(SystemConstants.SYSTEM_REPO_ID));
    assertNotNull(this.repositoryService.get(TEST_REPO_ID));
}
Also used : RestoreResult(com.enonic.xp.node.RestoreResult) RepositoryId(com.enonic.xp.repository.RepositoryId)

Aggregations

RepositoryId (com.enonic.xp.repository.RepositoryId)61 Test (org.junit.jupiter.api.Test)21 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)19 Branch (com.enonic.xp.branch.Branch)14 Repository (com.enonic.xp.repository.Repository)11 Node (com.enonic.xp.node.Node)9 ByteSource (com.google.common.io.ByteSource)8 IOException (java.io.IOException)7 PropertyTree (com.enonic.xp.data.PropertyTree)6 Segment (com.enonic.xp.blob.Segment)5 Context (com.enonic.xp.context.Context)5 ContextAccessor (com.enonic.xp.context.ContextAccessor)5 ContextBuilder (com.enonic.xp.context.ContextBuilder)5 BlobKey (com.enonic.xp.blob.BlobKey)4 EventPublisher (com.enonic.xp.event.EventPublisher)4 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)4 Project (com.enonic.xp.project.Project)4 DumpConstants (com.enonic.xp.repo.impl.dump.DumpConstants)4 DumpBlobRecord (com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord)4 RepositoryIds (com.enonic.xp.repository.RepositoryIds)4