use of com.enonic.xp.repository.BranchNotFoundException in project xp by enonic.
the class NodeServiceImpl method verifyBranchExists.
private void verifyBranchExists(Branch branch) {
NodeHelper.runAsAdmin(() -> {
final RepositoryId repoId = ContextAccessor.current().getRepositoryId();
final Repository repository = this.repositoryService.get(repoId);
if (repository == null) {
throw new RepositoryNotFoundException(repoId);
}
if (!repository.getBranches().contains(branch)) {
throw new BranchNotFoundException(branch);
}
});
}
use of com.enonic.xp.repository.BranchNotFoundException in project xp by enonic.
the class RepositoryServiceImpl method doDeleteBranch.
private Repository doDeleteBranch(final DeleteBranchParams params, final RepositoryId repositoryId, Repository previousRepository) {
// If the repository entry does not exist, throws an exception
previousRepository = previousRepository == null ? repositoryEntryService.getRepositoryEntry(repositoryId) : previousRepository;
if (previousRepository == null) {
throw new RepositoryNotFoundException(repositoryId);
}
// If the branch does not exist, throws an exception
final Branch branch = params.getBranch();
if (!previousRepository.getBranches().contains(branch)) {
throw new BranchNotFoundException(branch);
}
// If the root node exists, deletes it
if (getRootNode(previousRepository.getId(), branch) != null) {
deleteRootNode(branch);
}
// Updates the repository entry
return repositoryEntryService.removeBranchFromRepositoryEntry(repositoryId, branch);
}
Aggregations