public List getSelectedResourceTypes() {
    if (isModelNew()) { // 新增加
      return new ArrayList();
    } else { // 修改的
      NewsPapers newsPapers = (NewsPapers) getModel();
      // ebook.getId();
      Collection<HibernateExpression> expressions = new ArrayList<HibernateExpression>();
      HibernateExpression ex = new CompareExpression("rid", newsPapers.getId(), CompareType.Equal);
      expressions.add(ex);
      // List<ResourceResType> list =
      // controller.findBy(ResourceResType.class, 1, 1000, expressions);
      List<ResourceResType> list =
          getResourceService()
              .findResourceResTypeBy(1, Integer.MAX_VALUE, "rid", false, expressions);
      ArrayList<ResourceType> arrayList = new ArrayList<ResourceType>();
      for (ResourceResType resType : list) {
        // arrayList.add(getResourceService().getresType.getResTypeId());
        arrayList.add(getResourceService().getResourceType(resType.getResTypeId()));
      }

      return arrayList;
    }
  }
  @Override
  protected boolean persist(Object object) {
    try {
      NewsPapers newsPapers = (NewsPapers) object;
      String errorMessage = "";
      if (!isModelNew()) {
        if (getUploadFileImage() != null) { // 上传了封面图片
          File dir = new File(getResourceService().getChapterAddress(newsPapers.getId()));
          if (!dir.exists()) dir.mkdirs();
          String uploadfileName =
              getUploadFileImage()
                  .getFileName()
                  .substring(getUploadFileImage().getFileName().lastIndexOf("\\") + 1);

          boolean resIsRightFormat = isRightFormat(uploadfileName);
          if (!resIsRightFormat) {
            // 文件格式判断
            throw new Exception("图片格式不正确[gif/jpg/png],请重新选择!");
          }
          if (dir.exists()) { // 删除文件
            for (File file : dir.listFiles()) {
              if (file.getName().startsWith("cover")) {
                getResourceService().deleteFile(file.toString());
                // 同步删除图片:
                getResourceService()
                    .rsyncUploadFile(
                        ResourceUtil.RSYNC_TYPE_DEL, new String[] {file.getAbsolutePath()});
              }
            }
          }
          errorMessage = getResourceService().upload(getUploadFileImage(), "", dir);
          if (!"".equals(errorMessage)) throw new Exception(errorMessage);
          // 给文件重命名:
          File file = new File(dir + File.separator + uploadfileName); // 上传到服务器的文件名称
          String fileName = "cover." + uploadfileName.split("\\.")[1];

          File newFile = new File(dir + File.separator + fileName);
          file.renameTo(newFile);

          getUploadService().resizeCoverFile(dir.toString(), fileName);
          newsPapers.setImage(fileName);
          // 同步图片:
          getUploadService().rsyncDirectry(dir);
        }
        // ___________新增_______________
        Integer copyrighId = getCopyrightId();
        if (copyrighId != null && !"".equals(copyrighId)) {
          if (!copyrighId.equals(newsPapers.getCopyrightId())) { // 表明修改了
            newsPapers.setLastCopyrightId(newsPapers.getCopyrightId());
            newsPapers.setCopyrightId(copyrighId);
          }
        }
        UserImpl user = (UserImpl) getUser();
        newsPapers.setModifierId(user.getId());
        if (selectedResourceType.size() == 0) throw new Exception("请选择资源分类!");
        getResourceService().updateResource(newsPapers, ResourceAll.RESOURCE_TYPE_NEWSPAPER);
        // 根据资源id将引用关系先删除
        getResourceService().deleteResourceResType(newsPapers.getId());
        // 添加资源与资源列表关系表
        for (int i = 0; i < selectedResourceType.size(); i++) {
          ResourceType type = (ResourceType) selectedResourceType.get(i);
          ResourceResType rel = new ResourceResType();
          rel.setRid(newsPapers.getId());
          rel.setResTypeId(type.getId());
          getResourceService().addResourceResType(rel);
        }
      }
    } catch (Exception e) {
      getDelegate().setFormComponent(null);
      getDelegate().record(e.getMessage(), null);
      return false;
    }
    return true;
  }