Advertisement
psi_mmobile

Untitled

Oct 2nd, 2019
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.95 KB | None | 0 0
  1.     private String uploadFile(UploadedFile doc) {
  2.         UploadedFile myDoc = doc;
  3.         String path = null;
  4.         if (myDoc == null) {
  5.  
  6.         } else {
  7.             path =
  8. FILE_PATH + File.separator + new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date()) + "_" + myDoc.getFilename();
  9.  
  10.             System.out.println(path + " PATH + FILENAME ");
  11.             InputStream inputStream = null;
  12.             try {
  13.                 FileOutputStream out = new FileOutputStream(path);
  14.                 inputStream = myDoc.getInputStream();
  15.                 byte[] buffer = new byte[8192];
  16.                 int bytesRead = 0;
  17.                 while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
  18.                     out.write(buffer, 0, bytesRead);
  19.                 }
  20.                 out.flush();
  21.                 out.close();
  22.             } catch (Exception ex) {
  23.                 log.error(ex.getMessage(), ex);
  24.             } finally {
  25.                 try {
  26.                     inputStream.close();
  27.                 } catch (IOException ioex) {
  28.                     log.error(ioex.getMessage(), ioex);
  29.                 }
  30.             }
  31.         }
  32.         return path;
  33.     }
  34.  
  35.     public void setDocumentData(String path, int contentType, String fileName) {
  36.         AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
  37.         DCIteratorBinding attachDocIterator = ADFUtils.findIterator("AttachDocView2Iterator");
  38.         //ViewObject attachDocVo = am.getAttachDocView2();
  39.         Row newAttachDoc = attachDocIterator.getRowSetIterator().createRow();
  40.         newAttachDoc.setAttribute("DocumentDate", new oracle.jbo.domain.Date().getCurrentDate());
  41.         newAttachDoc.setAttribute("Name", fileName);
  42.  
  43.         newAttachDoc.setAttribute("FilePath", path);
  44.         newAttachDoc.setAttribute("ContentTypeId", contentType);
  45.  
  46.         attachDocIterator.getRowSetIterator().insertRow(newAttachDoc);
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement