コード例 #1
0
ファイル: DocInfoAction.java プロジェクト: rliangzi/lemon
  public String removeAll() {
    List<DocInfo> docInfos = docInfoManager.findByIds(selectedItem);

    docInfoManager.removeAll(docInfos);
    addActionMessage(messages.getMessage("core.success.delete", "删除成功"));

    return RELOAD;
  }
コード例 #2
0
ファイル: DocInfoAction.java プロジェクト: rliangzi/lemon
  public String input() {
    if (id > 0) {
      model = docInfoManager.get(id);
    }

    return INPUT;
  }
コード例 #3
0
ファイル: DocInfoAction.java プロジェクト: rliangzi/lemon
  public String save() throws Exception {
    DocInfo dest = null;

    if (id > 0) {
      dest = docInfoManager.get(id);
      beanMapper.copy(model, dest);
    } else {
      dest = model;

      String userId =
          userConnector
              .findByUsername(
                  SpringSecurityUtils.getCurrentUsername(), ScopeHolder.getUserRepoRef())
              .getId();
      dest.setUserId(Long.parseLong(userId));
    }

    new File("target/uploaded").mkdirs();

    File targetFile = new File("target/uploaded", attachment.getName());
    InputStream is = null;
    OutputStream os = null;

    try {
      is = new FileInputStream(attachment);
      os = new FileOutputStream(targetFile);
      IoUtils.copyStream(is, os);
    } finally {
      if (is != null) {
        is.close();
      }

      if (os != null) {
        os.close();
      }
    }

    dest.setPath(targetFile.getName());
    docInfoManager.save(dest);

    addActionMessage(messages.getMessage("core.success.save", "保存成功"));

    return RELOAD;
  }
コード例 #4
0
ファイル: DocInfoAction.java プロジェクト: rliangzi/lemon
  public String list() {
    List<PropertyFilter> propertyFilters =
        PropertyFilter.buildFromHttpRequest(ServletActionContext.getRequest());

    String userId =
        userConnector
            .findByUsername(SpringSecurityUtils.getCurrentUsername(), ScopeHolder.getUserRepoRef())
            .getId();
    propertyFilters.add(new PropertyFilter("EQL_userId", userId));
    page = docInfoManager.pagedQuery(page, propertyFilters);

    return SUCCESS;
  }
コード例 #5
0
ファイル: DocInfoAction.java プロジェクト: rliangzi/lemon
  public void exportExcel() throws Exception {
    List<PropertyFilter> propertyFilters =
        PropertyFilter.buildFromHttpRequest(ServletActionContext.getRequest());
    page = docInfoManager.pagedQuery(page, propertyFilters);

    List<DocInfo> docInfos = (List<DocInfo>) page.getResult();

    TableModel tableModel = new TableModel();
    tableModel.setName("doc info");
    tableModel.addHeaders("id", "name");
    tableModel.setData(docInfos);
    exportor.exportExcel(ServletActionContext.getResponse(), tableModel);
  }
コード例 #6
0
ファイル: DocInfoAction.java プロジェクト: rliangzi/lemon
  public void download() throws Exception {
    DocInfo docInfo = docInfoManager.get(id);
    File file = new File("target/uploaded", docInfo.getPath());
    InputStream is = null;

    try {
      is = new FileInputStream(file);
      IoUtils.copyStream(is, ServletActionContext.getResponse().getOutputStream());
    } finally {
      if (is != null) {
        is.close();
      }
    }
  }