示例#1
0
 @Override
 public String convertImgUrl(int size, String imgUrl) {
   try {
     List<AppboxImg> appboxImgList = appboxImgDao.findByProperty("imgUrl", imgUrl);
     if (appboxImgList.isEmpty()) {
       // imgUrl is "" or not exists in the appboxImg table
       return "";
     }
     String relativePath = "";
     switch (size) {
       case 0:
         relativePath = appboxImgList.get(0).getTinyPath();
         break;
       case 1:
         relativePath = appboxImgList.get(0).getMiddlePath();
         break;
       default:
         // TODO expand later
         relativePath = appboxImgList.get(0).getOriginPath();
     }
     return relativePath;
   } catch (DataAccessException dse) {
     log.error(dse.toString());
     throw new ServiceException("DataAccessException", dse);
   }
 }
示例#2
0
 /**
  * verify whether the image has been stored.
  *
  * @param imgUrl
  * @return
  */
 private boolean checkImgUrl(String imgUrl) {
   if (imgUrl.equals("")) {
     return true;
   }
   // TODO optimize this by adding 'limit 1'
   List<AppboxImg> appboxImgList = appboxImgDao.findByProperty("imgUrl", imgUrl);
   if (appboxImgList.isEmpty()) {
     return false;
   } else {
     return true;
   }
 }