Search in sources :

Example 6 with RepositoryNotFoundException

use of com.enonic.xp.repository.RepositoryNotFoundException 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);
}
Also used : Branch(com.enonic.xp.branch.Branch) BranchNotFoundException(com.enonic.xp.repository.BranchNotFoundException) RepositoryNotFoundException(com.enonic.xp.repository.RepositoryNotFoundException)

Aggregations

RepositoryNotFoundException (com.enonic.xp.repository.RepositoryNotFoundException)6 Repository (com.enonic.xp.repository.Repository)3 RepositoryId (com.enonic.xp.repository.RepositoryId)3 Branch (com.enonic.xp.branch.Branch)2 BranchNotFoundException (com.enonic.xp.repository.BranchNotFoundException)2 EditableRepository (com.enonic.xp.repository.EditableRepository)2 AttachedBinary (com.enonic.xp.node.AttachedBinary)1