Beispiel #1
0
  public List<IPost> findPostsByCriteria(
      Integer startIndice,
      Integer endIndice,
      Set<IUser> authors,
      Set<ICategory> categories,
      String text,
      String title,
      Date start,
      Date end)
      throws BlogException {

    HashMap<String, ICriteria> criterias =
        getCriterias(authors, categories, text, title, start, end);

    List<Post> postsSrv = null;
    try {
      postsSrv = bean.findPostsByCriteriaNotPrivate(criterias, startIndice, endIndice);
    } catch (EJBAccessException e) {
      throw new BlogException(
          null,
          BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
          Constants.HOME_PAGE);
    }
    if (postsSrv != null && !postsSrv.isEmpty()) {
      List<IPost> posts = converterPostList(postsSrv);
      return posts;
    }
    return new ArrayList<IPost>();
  }
Beispiel #2
0
 public IPost findPostId(int postid) throws BlogException {
   try {
     Post post = bean.findPostId(postid);
     log.debug("findPaostId : " + post.getPosttext());
     return (PostGWT) mapper.map(post, PostGWT.class);
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   } catch (MappingException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("post.no.error"),
         Constants.HOME_PAGE);
   }
 }
Beispiel #3
0
 public int countUserPosts(IUser user) throws BlogException {
   try {
     return bean.countUserPosts(user.getUserid());
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   }
 }
Beispiel #4
0
 /**
  * Supprime un article
  *
  * @param post article
  * @throws BlogException
  */
 public void removePost(IPost post) throws BlogException {
   try {
     bean.removePost(post.getPostid());
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   }
 }
Beispiel #5
0
 /**
  * Retourne un article par rapport � son titre
  *
  * @param title le titer
  * @return l'article trouv�
  * @throws BlogException
  */
 public PostGWT findPost(String title) throws BlogException {
   try {
     Post post = bean.findPost(title);
     return (PostGWT) mapper.map(post, PostGWT.class);
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   }
 }
Beispiel #6
0
 /**
  * Ajoute un article
  *
  * @param post article � ajouter
  * @throws BlogException
  * @throws ValidationException
  */
 public IPost addPost(IPost post) throws BlogException, ValidationException {
   Post postSrv = (Post) mapper.map(post, Post.class);
   try {
     postSrv = bean.addPost(postSrv);
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   }
   return (PostGWT) mapper.map(postSrv, PostGWT.class);
 }
Beispiel #7
0
 public List<IPost> findUserPosts(IUser user, int start, int end) throws BlogException {
   List<Post> postsSrv = null;
   try {
     postsSrv = bean.findUserPosts(user.getUserid(), start, end);
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   }
   List<IPost> posts = converterPostList(postsSrv);
   return posts;
 }
Beispiel #8
0
 /**
  * Retourne tous les articles de l'application
  *
  * @return tous les articles
  * @throws BlogException
  */
 public List<IPost> findAllPosts() throws BlogException {
   List<Post> postsSrv = null;
   try {
     if (getConnectedUser() != null) {
       postsSrv = bean.findAllPosts();
     } else {
       postsSrv = bean.findAllPostsNotPrivate();
     }
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   }
   List<IPost> posts = converterPostList(postsSrv);
   return posts;
 }
Beispiel #9
0
 public List<IPost> findPosts(int start, int end) throws BlogException {
   List<Post> postsSrv = null;
   try {
     log.info("connectedUSer findAllPost !!");
     if (getConnectedUser() != null) {
       log.info("connectedUSer findAllPost pas null !!");
       postsSrv = bean.findPosts(start, end);
     } else {
       log.info("connectedUSer findAllPost null!!");
       postsSrv = bean.findPostsNotPrivate(start, end);
     }
   } catch (EJBAccessException e) {
     throw new BlogException(
         null,
         BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
         Constants.HOME_PAGE);
   }
   List<IPost> posts = converterPostList(postsSrv);
   return posts;
 }
Beispiel #10
0
  public int countPostsByCriteria(
      Integer startIndice,
      Integer endIndice,
      Set<IUser> authors,
      Set<ICategory> categories,
      String text,
      String title,
      Date start,
      Date end)
      throws BlogException {
    HashMap<String, ICriteria> criterias =
        getCriterias(authors, categories, text, title, start, end);

    try {
      return bean.countPostsByCriteria(criterias, startIndice, endIndice);
    } catch (EJBAccessException e) {
      throw new BlogException(
          null,
          BlogInternationalizationUtils.getMessages().getString("acces.non.autorise"),
          Constants.HOME_PAGE);
    }
  }