示例#1
0
  public String input() {
    if (id > 0) {
      model = docInfoManager.get(id);
    }

    return INPUT;
  }
示例#2
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();
      }
    }
  }
示例#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;
  }