Search in sources :

Example 1 with BranchMapper

use of com.enonic.xp.lib.repo.mapper.BranchMapper in project xp by enonic.

the class CreateBranchHandler method doCreateBranch.

private BranchMapper doCreateBranch() {
    final CreateBranchParams createBranchParams = CreateBranchParams.from(branchId);
    final Branch createdBranch = repositoryServiceSupplier.get().createBranch(createBranchParams);
    return createdBranch == null ? null : new BranchMapper(createdBranch);
}
Also used : Branch(com.enonic.xp.branch.Branch) CreateBranchParams(com.enonic.xp.repository.CreateBranchParams) BranchMapper(com.enonic.xp.lib.repo.mapper.BranchMapper)

Example 2 with BranchMapper

use of com.enonic.xp.lib.repo.mapper.BranchMapper in project xp by enonic.

the class DeleteBranchHandler method doDeleteBranch.

private BranchMapper doDeleteBranch() {
    final RepositoryId repositoryId = ContextAccessor.current().getRepositoryId();
    if (isProtectedBranch(repositoryId, Branch.from(this.branchId))) {
        throw new RepositoryExeption("No allowed to delete branch [" + this.branchId + "] in repository [" + repositoryId + "]");
    }
    final DeleteBranchParams deleteBranchParams = DeleteBranchParams.from(branchId);
    final Branch deletedBranch = repositoryServiceSupplier.get().deleteBranch(deleteBranchParams);
    return deletedBranch == null ? null : new BranchMapper(deletedBranch);
}
Also used : RepositoryExeption(com.enonic.xp.repository.RepositoryExeption) Branch(com.enonic.xp.branch.Branch) RepositoryId(com.enonic.xp.repository.RepositoryId) DeleteBranchParams(com.enonic.xp.repository.DeleteBranchParams) BranchMapper(com.enonic.xp.lib.repo.mapper.BranchMapper)

Aggregations

Branch (com.enonic.xp.branch.Branch)2 BranchMapper (com.enonic.xp.lib.repo.mapper.BranchMapper)2 CreateBranchParams (com.enonic.xp.repository.CreateBranchParams)1 DeleteBranchParams (com.enonic.xp.repository.DeleteBranchParams)1 RepositoryExeption (com.enonic.xp.repository.RepositoryExeption)1 RepositoryId (com.enonic.xp.repository.RepositoryId)1