@Override
 @Transactional
 public List<BookEntity> getBooksByAuthor(int authorId, int offset, int limit) {
   List<BookEntity> books;
   if (sessionUtils.isUserWithRole(RolesEnum.admin)
       || (sessionUtils.isUserWithRole(RolesEnum.author)
           && sessionUtils.getUserByToken().getAuthorId() == authorId)) {
     books = bookDao.getBooksByAuthor(authorId, offset, limit, null);
   } else {
     books = bookDao.getBooksByAuthor(authorId, offset, limit, BookStatusesEnum.ACTIVE);
   }
   return books != null ? books : null;
 }
 @Override
 @Transactional(propagation = Propagation.REQUIRED)
 public List<BookEntity> getBooks(int offset, int limit)
     throws NoSuchEntityException, NotSupportedFieldException, ForbiddenException,
         AuthRequiredException {
   sessionUtils.allowedForUserWithRole(RolesEnum.admin);
   List<BookEntity> books = bookDao.getNotNull(offset, limit);
   return books;
 }
 @Override
 @Transactional(propagation = Propagation.REQUIRED)
 public List<BookEntity> getBooksByIds(
     Iterable<Integer> ids, int count, BookStatusesEnum statusEnum)
     throws NotSupportedFieldException, NoSuchEntityException, ForbiddenException {
   if (ids == null || !ids.iterator().hasNext()) return Lists.newArrayList();
   List<Criterion> criterions = Lists.newArrayList();
   if (statusEnum != null) {
     criterions.add(Restrictions.eq("status", statusEnum));
   } else {
     criterions.add(Restrictions.eq("status", BookStatusesEnum.ACTIVE));
   }
   criterions.add(Restrictions.in("id", Lists.newArrayList(ids)));
   List<BookEntity> res = bookDao.get(0, count, criterions);
   if (sessionUtils.isUserWithAnotherRole(RolesEnum.admin)) {
     if (statusEnum != null && !BookStatusesEnum.ACTIVE.equals(statusEnum)) {
       bookAvailabilityService.areBooksAvailable(res);
     }
   }
   return res;
 }