public PortalImportTask(ServletContext servletContext) { super(); this.mServletContext = servletContext; try { mDS = DatabaseServive.getInstance(); mPhotoCollection = mDS.getCollection("photo"); } catch (Exception e) { e.printStackTrace(); } }
private void saveThumbnailImages(DBObject photo, BufferedImage[] images, String suffix) { for (int i = 0; i < IMAGE_TYPES.length; i++) { String fileName = IMAGE_TYPES[i] + suffix; OutputStream os = mDS.getFileOutputStream(fileName, "image/png"); try { if (os != null) { ImageIO.write(images[i], "png", os); photo.put(IMAGE_TYPES[i] + "_image_url", FILE_URL + fileName); } } catch (IOException e) { e.printStackTrace(); } finally { if (os != null) { try { os.close(); } catch (IOException e) { e.printStackTrace(); } } images[i].flush(); } } }