예제 #1
0
  private String processAttachFileToAsset(FormData uploadItem) throws IOException {

    FileManagerUtils manager = getFileManager();

    // If the file it doesn't exist.
    if ("".equals(uploadItem.getFile().getName())) {
      throw new IOException("No file selected.");
    }

    manager.attachFile(uploadItem);
    uploadItem.getFile().getInputStream().close();

    return "OK";
  }
예제 #2
0
  /**
   * Posting accepts content of various types - may be an attachement for an asset, or perhaps a
   * repository import to process.
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html");
    FormData uploadItem = FileManagerUtils.getFormData(request);

    if (uploadItem.getFile() != null && uploadItem.getUuid() != null) {
      // attaching to an asset.
      response.getWriter().write(processAttachFileToAsset(uploadItem));

      return;
    }
    response.getWriter().write("NO-SCRIPT-DATA");
  }