Example #1
0
 /** Drops underlying database table using DAOs. */
 public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
   MenuDao.dropTable(db, ifExists);
   ChannelDao.dropTable(db, ifExists);
   NewsDao.dropTable(db, ifExists);
   NewsDetailDao.dropTable(db, ifExists);
   ImageDao.dropTable(db, ifExists);
   HeaderImageDao.dropTable(db, ifExists);
 }
Example #2
0
 /** Creates underlying database table using DAOs. */
 public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
   MenuDao.createTable(db, ifNotExists);
   ChannelDao.createTable(db, ifNotExists);
   NewsDao.createTable(db, ifNotExists);
   NewsDetailDao.createTable(db, ifNotExists);
   ImageDao.createTable(db, ifNotExists);
   HeaderImageDao.createTable(db, ifNotExists);
 }
Example #3
0
  @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  public void deleteImage(User editor, Image image) {
    EditHistoryDto info = new EditHistoryDto();

    info.setEditor(editor.getId());
    info.setMsgid(image.getTopicId());
    info.setOldimage(image.getId());
    info.setObjectType(EditHistoryObjectTypeEnum.TOPIC);

    imageDao.deleteImage(image);

    editHistoryService.insert(info);
    topicDao.updateLastmod(image.getTopicId(), false);
  }
Example #4
0
  /**
   * Takes in an InputStream representing the submitted image file and a String representing the
   * submitted URL, processes and stores the image, and returns a redirect to the image's results
   * page.
   *
   * @param inputStream InputStream representing the image to be processed
   * @param url String representing the URL of the image
   * @return a redirect to the image's results page
   * @throws IOException
   * @throws SQLException
   */
  @Override
  public String processInputStream(InputStream inputStream, String url)
      throws IOException, SQLException {
    Image image = new Image();
    File tempFile = ImageOperations.streamToFile(inputStream);
    new ImageOperations()
        .fillFields(image, tempFile); // Sends image file to the DatabaseOperations object
    Image tempImg;

    try {
      if ((tempImg = dBOps.imageBlobAlreadyExists(image)) == null) {
        dBOps.addEntity(image);
        aPII.tagImageUrl(image, url);
      } else {
        image.setID(tempImg.getID());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    String id = cryptoHandler.encryptId(image.getID());
    return id;
  } /* NOTE: Change domain if switching to another server. */
Example #5
0
  /**
   * Takes in an InputStream representing the submitted image file from the user's computer, uploads
   * the image to imgur for auto-tagging, processes and stores the image, and returns a redirect to
   * the image's results page.
   *
   * @param inputStream InputStream representing the image to be processed
   * @return a redirect to the image's results page
   * @throws IOException
   * @throws SQLException
   */
  @Override
  public String processInputStream(InputStream inputStream) throws IOException, SQLException {
    Image image = new Image();
    File tempFile = ImageOperations.streamToFile(inputStream);
    fillFields(image, tempFile);
    String imgurUploadUrl;
    Image tempImg;
    try {
      if ((tempImg = dBOps.imageBlobAlreadyExists(image)) == null) {
        dBOps.addEntity(image);
        imgurUploadUrl = aPII.uploadImage(tempFile);
        aPII.tagImageUrl(image, imgurUploadUrl);
        aPII.deleteImageFromImgur();
      } else {
        image.setID(tempImg.getID());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    String id = cryptoHandler.encryptId(image.getID());
    return id;
  }