Ejemplo n.º 1
0
 @Override
 protected void prepareModel() throws Exception {
   if (id == null) {
     document = new Document();
   } else {
     document = officeManager.getDocument(id);
   }
 }
Ejemplo n.º 2
0
  // 上传正文
  @Override
  public String input() throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    MultiPartRequestWrapper wrapper = (MultiPartRequestWrapper) request;
    File filePath = wrapper.getFiles("Filedata")[0];
    String fileName = request.getParameter("Filename");
    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(filePath));
    Document document = new Document();

    document.setFileSize(bis.available());
    document.setFileName(fileName);
    document.setCreatedTime(new Date());
    if (request.getParameter("taskId") != null) {
      long taskId = Long.valueOf(request.getParameter("taskId"));
      WorkflowTask task = ApiFactory.getTaskService().getTask(taskId);
      document.setTaskMode(task.getProcessingMode());
      document.setTaskName(task.getName());
      document.setWorkflowId(task.getProcessInstanceId());
      document.setCompanyId(task.getCompanyId());
      document.setCreator(task.getTransactor());
      document.setCreatorName(task.getTransactorName());
    }
    String fileType = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
    if (!("pdf").equals(fileType)) {
      fileType = "." + fileType;
    }
    document.setFileType(fileType);
    officeManager.saveDocument(document);
    DocumentFile file = new DocumentFile();
    byte[] content = null;
    try {
      content = new byte[bis.available()];
      bis.read(content);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      bis.close();
    }
    file.setFileBody(content);
    file.setDocumentId(document.getId());
    file.setCompanyId(document.getCompanyId());
    officeManager.saveDocumentFile(file);
    return "DOCUMENTID:" + document.getId();
  }
Ejemplo n.º 3
0
 /** 删除正文 */
 @Action("office-deleteText")
 public String deleteText() throws Exception {
   officeManager.deleteText(id);
   // renderText("ok");
   return list();
 }