/** * 删除某条信息 * * @param siteid * @param obj_id * @return * @throws IOException */ public static boolean deleteFileById(int siteid, int obj_id) throws Exception { FckUploadFileBean fufb = (FckUploadFileBean) namedUniqueResult("GET_UPLOAD_FILE", obj_id); if (fufb != null && fufb.getSite().getId() == siteid) { delete(fufb); FCK_UploadManager.getUploadHandler().remove(fufb); return true; } return false; }
/** * 删除某条信息 * * @param siteid * @param obj_id * @return * @throws IOException */ public static boolean deleteFileById(int userid, String ssn_id, int obj_id) throws Exception { FckUploadFileBean fufb = (FckUploadFileBean) namedUniqueResult("GET_UPLOAD_FILE", obj_id); if (fufb != null && fufb.getUser().getId() == userid && StringUtils.equals(fufb.getSessionId(), ssn_id)) { delete(fufb); FCK_UploadManager.getUploadHandler().remove(fufb); return true; } return false; }
/** * 删除被某篇文章引用的所有上传的文件 * * @param site_id * @param ref_id * @param ref_type * @return * @throws IOException */ public static int deleteFilesByRef(Session ssn, int site_id, int ref_id, int ref_type) throws Exception { List files = findNamedAll("GET_UPLOAD_FILE_BY_REF", site_id, ref_id, ref_type); for (int i = 0; i < files.size(); i++) { FckUploadFileBean fufb = (FckUploadFileBean) files.get(i); if (StringUtils.isNotEmpty(fufb.getSavePath())) { FCK_UploadManager.getUploadHandler().remove(fufb); } int photo_site = DLOG4JUtils.sizeInKbytes(fufb.getFileSize()); fufb.getSite().getCapacity().incDiaryUsed(-photo_site); ssn.delete(fufb); } return files.size(); }
/** * 写入一个上传文件的信息 * * @see com.liusoft.dlog4j.upload.SecurityFCKUploadServlet#doPost(HttpServletRequest, * HttpServletResponse) * @param fbean */ public static void createUploadFileItem(FckUploadFileBean fbean) { if (fbean.getUploadTime() == null) fbean.setUploadTime(new Date()); save(fbean); }