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();
}
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;
}
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()));
});
}
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));
});
}
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));
}
Aggregations