示例#1
0
 /**
  * 获取某种文件的分页
  *
  * @param adminId
  * @param folderId
  * @param check
  * @param pageNum
  * @return
  * @throws FolderNotFoundException
  */
 public PageVo<ArticleVo> getArticlePageByFolderId(
     long adminId, long folderId, ArticleConstant.check check, int pageNum)
     throws FolderNotFoundException {
   PageVo<ArticleVo> pageVo = new PageVo<ArticleVo>(pageNum);
   pageVo.setRows(20);
   List<ArticleVo> list = new ArrayList<ArticleVo>();
   int count = 0;
   if (folderId == 0) {
     count = this.getArticleCountByAdminIdAndFolderId(adminId, 0, check);
     list =
         this.getArticleListByAdminIdAndFolderId(
             adminId, 0, check, pageVo.getOffset(), pageVo.getRows());
   } else {
     list =
         this.getArticleListByAdminIdAndFolderId(
             adminId, folderId, check, pageVo.getOffset(), pageVo.getRows());
     count = this.getArticleCountByAdminIdAndFolderId(adminId, folderId, check);
   }
   for (ArticleVo article : list) {
     try {
       article.setFolder(folderService.getFolderById(article.getFolderId()));
       article.setFolderPathList(folderService.getFolderPathListByFolderId(article.getFolderId()));
     } catch (FolderNotFoundException e) {
       article.setFolder(new Folder());
     }
   }
   pageVo.setList(list);
   pageVo.setCount(count);
   return pageVo;
 }
示例#2
0
  /** Añade a las respectivas carpetas la primera vez que un mensaje es creado */
  private void addMessageToFolderFirst(Message message) {

    for (Folder f : message.getSender().getFolders()) {
      if (f.getName().equals("OutBox") && f.getIsSystem()) {
        folderService.addMessage(f, message);
      }
    }

    for (Actor recipient : message.getRecipients()) {
      for (Folder f : recipient.getFolders()) {
        if (f.getName().equals("InBox") && f.getIsSystem()) {
          folderService.addMessage(f, message);
        }
      }
    }
  }
示例#3
0
 /**
  * 得到目录的显示的文件分页
  *
  * @param folderId
  * @return pageVo
  * @throws FolderNotFoundException
  */
 @Cacheable(value = "article")
 public PageVo<ArticleVo> getArticlePageByFolderId(long folderId, int pageNum, int rows)
     throws FolderNotFoundException {
   PageVo<ArticleVo> pageVo = new PageVo<ArticleVo>(pageNum);
   FolderVo folder = folderService.getFolderById(folderId);
   pageVo.setRows(rows);
   pageVo.setCount(articleDao.getArticleCountOfDisplayByPath(folder.getPath()));
   List<ArticleVo> articlelist =
       articleDao.getArticleListOfDisplayByPath(
           folder.getPath(), pageVo.getOffset(), pageVo.getRows());
   for (ArticleVo artcle : articlelist) {
     FolderVo artcleFolder = folderService.getFolderById(artcle.getFolderId());
     artcle.setFolder(artcleFolder);
   }
   pageVo.setList(articlelist);
   return pageVo;
 }
示例#4
0
 /**
  * @param adminId
  * @param folderId
  * @return
  * @throws FolderNotFoundException
  */
 public int getArticleCountByAdminIdAndFolderId(
     long adminId, long folderId, ArticleConstant.check check) throws FolderNotFoundException {
   String path = "";
   if (folderId != 0) {
     Folder folder = folderService.getFolderById(folderId);
     path = folder.getPath();
   }
   return articleDao.getArticleCountByAdminIdAndPath(adminId, path, check);
 }
示例#5
0
  // req: 24.2
  public void deleteMessageFromFolder(Message message, Folder folder) {
    Assert.notNull(message);
    Assert.isTrue(message.getId() != 0);
    Assert.notNull(folder);
    Assert.isTrue(folder.getId() != 0);

    Assert.isTrue(
        folder.getActor().equals(actorService.findByPrincipal()),
        "Only the owner of the folder can delete a message");

    folderService.removeMessage(folder, message);
  }
示例#6
0
 /**
  * @param adminId
  * @param folderId
  * @param offset
  * @param rows
  * @return
  * @throws FolderNotFoundException
  */
 public List<ArticleVo> getArticleListByAdminIdAndFolderId(
     long adminId, long folderId, ArticleConstant.check check, long offset, long rows)
     throws FolderNotFoundException {
   String path = "";
   if (folderId != 0) {
     Folder folder = folderService.getFolderById(folderId);
     path = folder.getPath();
   }
   List<ArticleVo> articleList =
       articleDao.getArticleListByAdminIdAndPath(adminId, path, check, offset, rows);
   return articleList;
 }
示例#7
0
 /**
  * @param folderId
  * @param adminId
  * @param title
  * @param summary
  * @param status
  * @param content
  * @param file
  * @param createTime
  * @return
  * @throws FolderNotFoundException
  * @throws UploadException
  * @throws IOException
  */
 @CacheEvict(value = "article", allEntries = true)
 public Article addArticle(
     long folderId,
     long adminId,
     String title,
     String summary,
     ArticleConstant.Status status,
     String content,
     MultipartFile file,
     String createTime)
     throws FolderNotFoundException, UploadException, IOException {
   FolderVo folder = folderService.getFolderById(folderId);
   Article article = new Article();
   Date now = new Date();
   String picture = "";
   if (file != null && !file.isEmpty()) {
     picture = MediaUtils.saveImage(file, folder.getWidth(), folder.getHeight());
   }
   if (folder.getCheck().equals(FolderConstant.check.yes)) {
     article.setCheck(ArticleConstant.check.init);
   } else {
     article.setCheck(ArticleConstant.check.yes);
   }
   article.setFolderId(folder.getFolderId());
   article.setPath(folder.getPath());
   article.setAdminId(adminId);
   article.setTitle(title);
   article.setSummary(summary);
   article.setContent(content);
   article.setViewCount(0);
   article.setCommentCount(0);
   article.setPicture(picture);
   article.setStatus(status);
   if (StringUtils.isBlank(createTime)) {
     article.setCreateTime(now);
   } else {
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
     Date date;
     try {
       date = sdf.parse(createTime);
     } catch (ParseException e) {
       date = now;
     }
     article.setCreateTime(date);
   }
   article.setUpdateTime(now);
   articleDao.addArticle(article);
   return articleDao.getArticleById(article.getArticleId());
 }