Search in sources :

Example 1 with RepositoryExeption

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

the class BinaryServiceImpl method get.

@Override
public ByteSource get(final RepositoryId repositoryId, final AttachedBinary attachedBinary) {
    final Segment segment = RepositorySegmentUtils.toSegment(repositoryId, NodeConstants.BINARY_SEGMENT_LEVEL);
    final BlobRecord record = blobStore.getRecord(segment, BlobKey.from(attachedBinary.getBlobKey()));
    if (record == null) {
        throw new RepositoryExeption("Cannot load binary with key [" + attachedBinary.getBlobKey() + "], not found");
    }
    return record.getBytes();
}
Also used : BlobRecord(com.enonic.xp.blob.BlobRecord) RepositoryExeption(com.enonic.xp.repository.RepositoryExeption) Segment(com.enonic.xp.blob.Segment)

Example 2 with RepositoryExeption

use of com.enonic.xp.repository.RepositoryExeption 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

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