Example #1
0
  public String removeAll() {
    List<DocInfo> docInfos = docInfoManager.findByIds(selectedItem);

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

    return RELOAD;
  }
Example #2
0
  public String input() {
    if (id > 0) {
      model = docInfoManager.get(id);
    }

    return INPUT;
  }
Example #3
0
  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;
  }
Example #4
0
  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;
  }
Example #5
0
  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);
  }
Example #6
0
  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();
      }
    }
  }