@Override
  protected Bitmap doInBackground(Void... params) {
    Bitmap bmp = null;

    if (_isLocal) {
      String productCatalogData = CardHelper.getDatabseValue(Integer.toString(_EntityID));
      if (productCatalogData != null) {
        bmp = stringToBitmap1(productCatalogData);
      }
    } else {
      WebApiRequest_Test webAPIRequest = new WebApiRequest_Test();
      try {
        _getPortalEntityResponse = (GetPortalEntityResponse) webAPIRequest.Execute(createRequest());
      } catch (IllegalStateException | IOException | JSONException e) {

        e.printStackTrace();
      }

      if (_getPortalEntityResponse != null) {
        try {
          String productCatalogData = _getPortalEntityResponse.jsonObject.getString("BgImage");
          bmp = stringToBitmap1(productCatalogData);
          _getPortalEntityResponse.rowInsertInPortalEntitiyDb(_getPortalEntityResponse.jsonObject);

        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    return bmp;
  }
 public static SparqlQueryResults getQueryResults(String tabName) {
   SparqlQuery query = new SparqlQuery();
   GetSparqlQuery query_submit = new GetSparqlQuery(query);
   SparqlQueryResults thePlatforms = null;
   String query_json = null;
   try {
     query_json = query_submit.executeQuery(tabName);
     // System.out.println("query_json = " + query_json);
     thePlatforms = new SparqlQueryResults(query_json, false);
   } catch (IllegalStateException | IOException | NullPointerException e1) {
     e1.printStackTrace();
   }
   return thePlatforms;
 }
Esempio n. 3
0
 // for /metadata HTTP GET requests
 public static Result index() {
   SparqlQuery query = new SparqlQuery();
   GetSparqlQuery query_submit = new GetSparqlQuery(query);
   SparqlQueryResults theResults;
   String tabName = "InstrumentModels";
   String query_json = null;
   System.out.println("Instrument.java is requesting: " + tabName);
   try {
     query_json = query_submit.executeQuery(tabName);
     // System.out.println("query_json = " + query_json);
     theResults = new SparqlQueryResults(query_json, false);
   } catch (IllegalStateException | IOException | NullPointerException e1) {
     return internalServerError(error_page.render(e1.toString(), tabName));
     // e1.printStackTrace();
   }
   System.out.println("Instrument index() was called!");
   return ok(hierarchy_browser.render(theResults, tabName));
 } // /index()
 /**
  * 测试:上传单个文件
  *
  * @param picture
  * @return
  */
 @RequestMapping(value = "/addPicture", method = RequestMethod.POST)
 public String addPicture2(MultipartFile picture) {
   logger.info("POST---文件上传开始---");
   String fileName = picture.getOriginalFilename();
   logger.info("原文件名" + fileName);
   String path = "O:\\picc\\";
   String newFileName = UUID.randomUUID() + fileName.substring(fileName.lastIndexOf("."));
   logger.info(newFileName);
   File newFile = new File(path + newFileName);
   logger.info(newFile);
   try {
     picture.transferTo(newFile);
   } catch (IllegalStateException | IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   logger.info("上传成功");
   return "showUser";
 }
  @RequestMapping(value = "/roomrent/fileUpload", method = RequestMethod.POST)
  public ModelAndView save(File_Vo vo, HttpServletRequest request) {

    ModelAndView mav = new ModelAndView("redirect:/roomrent/fileList");

    HttpSession session = request.getSession();
    String r_path = session.getServletContext().getRealPath("/");
    String file_path = "\\file\\";
    StringBuffer path = new StringBuffer();
    path.append(r_path).append(file_path);

    String orifn = vo.getFile().getOriginalFilename();
    long size = vo.getFile().getSize();
    String type = vo.getFile().getContentType();

    path.append(orifn);
    File f = new File(path.toString());
    try {
      vo.getFile().transferTo(f);
    } catch (IllegalStateException | IOException e) {
      e.printStackTrace();
    }
    vo.setFile_name(orifn);
    vo.setFile_path(path.toString());
    vo.setFile_type(type);
    vo.setFile_size(size);

    String mem_code = "";
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    Object pricipal = auth.getPrincipal();
    if (pricipal != null && pricipal instanceof Member_Vo_Security) {
      mem_code = ((Member_Vo_Security) pricipal).getMem_code();
    }
    vo.setMem_code(mem_code);

    service.file_Add(vo);

    mav.addObject("vo", vo);
    return mav;
  }
Esempio n. 6
0
  // Ftp 서버의 파일을 지정한
  private void ftpFile_DownLoad() {

    JFileChooser jfiledialog = new JFileChooser();
    jfiledialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    // 파일선택 창을 띄웁니다.
    jfiledialog.setCurrentDirectory(new File(text_path.getText()));
    int ret = jfiledialog.showOpenDialog(this);

    // 폴더를 선택 했다면 선택 폴더의 모든 이미지를 불러옵니다.
    if (ret == jfiledialog.APPROVE_OPTION) {

      // 커서 변경(모래시계)
      this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

      // 선택정보를 불러옵니다.
      int row = table_ftp_view.getSelectedRow();
      int col = table_ftp_view.getColumnCount();

      Vector<Object> temp = new Vector<Object>();

      for (int i = 0; i < col; i++) {
        temp.add(dtm.getValueAt(row, i));
      }

      // ftp서버에 접속합니다.
      FTPClient ftpConn = new FTPClient();

      try {
        ftpConn.connect(Server_Config.getFTPIP(), Server_Config.getFTPPORT());
        ftpConn.login(Server_Config.getFTPID(), Server_Config.getFTPPW());

      } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
        // TODO Auto-generated catch block
        JOptionPane.showMessageDialog(this, "접속에 실패 했습니다.");
        e.printStackTrace();
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        return;
      }

      // 단독폴더 경로를 설정합니다.
      try {
        ftpConn.changeDirectory(Server_Config.getFTPMARTPATH());
      } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
        // TODO Auto-generated catch block

        JOptionPane.showMessageDialog(this, "디렉토리 변경에 실패 했습니다.");
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        e.printStackTrace();
        return;
      } catch (NullPointerException e) {

        JOptionPane.showMessageDialog(this, "단독폴더경로 설정을 하셔야 합니다. 환경설정에서 설정해 주세요");
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        e.printStackTrace();
        return;
      }

      // 파일을 찾습니다.
      String file_name = temp.get(1) + "." + temp.get(2);
      System.out.println(file_name);
      // 파일을 삭제합니다.

      File dirFile = new File(jfiledialog.getSelectedFile().toString() + "/" + file_name.trim());

      try {
        if (!dirFile.isFile()) {
          dirFile.createNewFile();
        }
      } catch (IOException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
        JOptionPane.showMessageDialog(this, "파일 다운로드 하지 못했습니다. \r\n" + e2.getMessage());
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        return;
      }

      try {
        try {
          ftpConn.download(file_name.trim(), dirFile);
        } catch (FTPDataTransferException | FTPAbortedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          JOptionPane.showMessageDialog(this, "파일 다운로드 하지 못했습니다. \r\n" + e.getMessage());
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          return;
        }
      } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        JOptionPane.showMessageDialog(this, "파일 다운로드를 하지 못했습니다. \r\n" + e1.getMessage());
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        return;
      }

      // 마무리합니다.
      try {
        if (ftpConn.isConnected()) {
          ftpConn.disconnect(true);
        }
      } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      JOptionPane.showMessageDialog(this, "파일 다운로드 완료 \r\n 정상적으로 다운로드 되었습니다.");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
  }
Esempio n. 7
0
  // 선택된 이미지를 삭제 합니다.
  private void ftp_image_delete() {

    // 커서 변경(모래시계)
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

    // 선택정보를 불러옵니다.
    int row = table_ftp_view.getSelectedRow();
    int col = table_ftp_view.getColumnCount();

    Vector<Object> temp = new Vector<Object>();

    for (int i = 0; i < col; i++) {
      temp.add(dtm.getValueAt(row, i));
    }

    FTPClient ftpConn = new FTPClient();

    try {
      ftpConn.connect(Server_Config.getFTPIP(), Server_Config.getFTPPORT());
      ftpConn.login(Server_Config.getFTPID(), Server_Config.getFTPPW());

    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      JOptionPane.showMessageDialog(this, "접속에 실패 했습니다.");
      e.printStackTrace();
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 단독폴더 경로를 설정합니다.
    try {
      ftpConn.changeDirectory(Server_Config.getFTPMARTPATH());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block

      JOptionPane.showMessageDialog(this, "디렉토리 변경에 실패 했습니다.");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    } catch (NullPointerException e) {

      JOptionPane.showMessageDialog(this, "단독폴더경로 설정을 하셔야 합니다. 환경설정에서 설정해 주세요");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    }

    String file_name = temp.get(1) + "." + temp.get(2);
    System.out.println(file_name);
    // 파일을 삭제합니다.

    try {
      ftpConn.deleteFile(file_name.trim());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
      JOptionPane.showMessageDialog(this, "파일을 삭제 하지 못했습니다.");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 서버에서 삭제 합니다.

    // 이미지디비에 파일을 삭제 하기 위해 쿼리를 작성합니다.
    String query =
        "Delete From Ftp_Image Where Barcode='"
            + temp.get(1).toString().trim()
            + "' and Path_Gubun='0' ";

    // 업로드한 정보를 매장 DB서버에 저장 합니다.
    /*if(!ms_connect.connect_errorCheck()){
    	JOptionPane.showMessageDialog(this, "디비에서 파일을 삭제하지 못했습니다.");
    	this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    	return;
    }*/

    ms_connect.setImageSetting();
    int result = ms_connect.connect_update(query);
    switch (result) {
      case 0:
        JOptionPane.showMessageDialog(this, "선택한 파일이 삭제 되었습니다.");
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        viewImgaeSearch();
        break;
      default:
        JOptionPane.showMessageDialog(this, "삭제 하지 못했습니다.");
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        break;
    }

    // 마무리합니다.
    try {
      if (ftpConn.isConnected()) {
        ftpConn.disconnect(true);
      }
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Esempio n. 8
0
  // 파일을 FTP서버로 업로드 합니다.
  private void uploadImage() {

    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

    // FTP로 이미지를 업로드 합니다.
    // FTP 서버에 접속 합니다.
    FTPClient ftpConn = new FTPClient();

    try {
      ftpConn.connect(Server_Config.getFTPIP(), Server_Config.getFTPPORT());
      ftpConn.login(Server_Config.getFTPID(), Server_Config.getFTPPW());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      JOptionPane.showMessageDialog(this, "접속에 실패 했습니다.");
      e.printStackTrace();
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 단독폴더 경로를 설정합니다.
    try {
      ftpConn.changeDirectory(Server_Config.getFTPMARTPATH());
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      // 디렉토리 없어서 오류가발생했다면
      String test;
      try {
        // 현재 디렉토리를 체크하고
        test = ftpConn.currentDirectory();
        System.out.println(test);
        // 그것이 루트 디렉토리라면
        if (test.equals("/")) {
          // 디렉토리를 생성한다.
          ftpConn.createDirectory(Server_Config.getFTPMARTPATH());
        }
      } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      JOptionPane.showMessageDialog(this, "디렉토리 변경에 실패 했습니다. 다시 시도해 주세요!");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    } catch (NullPointerException e) {

      JOptionPane.showMessageDialog(this, "단독폴더경로 설정을 하셔야 합니다.");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      e.printStackTrace();
      return;
    }

    // 전송할 파일을 불러옵니다.
    List<String> temp = list_image.getSelectedValuesList();
    if (temp.size() <= 0) {
      JOptionPane.showMessageDialog(this, "업로드할 파일을 선택해 주세요!");
      this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      return;
    }

    // 파일을 업로드 합니다.
    ArrayList<String> queryList = new ArrayList<String>();

    // 실패 파일을 저장합니다.
    ArrayList<String> uploadFail = new ArrayList<String>();

    for (String file : temp) {

      File tempFile = new File(text_path.getText(), file);

      if (fileSizeCheck(tempFile)) {
        try {
          ftpConn.upload(tempFile);
        } catch (IllegalStateException
            | IOException
            | FTPIllegalReplyException
            | FTPException
            | FTPDataTransferException
            | FTPAbortedException e) {
          // TODO Auto-generated catch block
          JOptionPane.showMessageDialog(this, "파일을 업로드 하지 못했습니다.");
          e.printStackTrace();
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          return;
        }

        // 이미지디비에 저장하기 위해 쿼리를 모아 둡니다.
        String query =
            "Insert into FTP_Image values('"
                + file.substring(0, file.indexOf("."))
                + "', '"
                + Server_Config.getFTPMARTPATH()
                + "', '0', '', '"
                + file.substring(file.indexOf(".") + 1, file.length())
                + "', '')";
        queryList.add(query);
      } else {
        // 업로드 실패시 저장합니다.
        uploadFail.add(tempFile.getName());
      }
    }

    // 저장할 상품이 있을때만 합니다.
    if (queryList.size() > 0) {
      ms_connect.setImageSetting();
      int result = ms_connect.connect_update(queryList);
      switch (result) {
        case 0:
          String queryOver =
              "Delete From Ftp_Image Where idx in( select a.idx as idx "
                  + "From Ftp_Image A INNER JOIN ( Select Min(idx) as idx, barcode, count(*) as overlapCount "
                  + "From Ftp_Image Where path_gubun='0' and path='"
                  + Server_Config.getFTPMARTPATH()
                  + "' Group by barcode Having count(*) > 1 ) B "
                  + "on a.barcode = b.barcode and A.idx <> B.idx and a.path_gubun='0' and path='"
                  + Server_Config.getFTPMARTPATH()
                  + "')";

          ms_connect.connect_update(queryOver);
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          JOptionPane.showMessageDialog(this, "저장이 완료 되었습니다.");
          // 검색창에 파일을 표시합니다.
          viewImgaeSearch();
          break;
        default:
          this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          JOptionPane.showMessageDialog(this, "저장을 완료 하지 못했습니다.");
          break;
      }
    }

    // 마무리합니다.
    try {
      if (ftpConn.isConnected()) {
        ftpConn.disconnect(true);
      }
    } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }