Changeset 10749 for extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/ImageDaoImpl.java
- Timestamp:
- May 3, 2011, 8:25:38 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/ImageDaoImpl.java
r10719 r10749 141 141 public boolean create(Image image, Double chunkSize) throws FileAlreadyExistsException, IOException, 142 142 ProxyAuthenticationException, NoSuchAlgorithmException, WrongChunkSizeException, JiwigoException { 143 if (exists(image)) { 144 throw new FileAlreadyExistsException("Photo already exists"); 145 } 143 146 //thumbnail converted to base64 144 147 BASE64Encoder base64 = new BASE64Encoder(); … … 196 199 return reussite; 197 200 201 } 202 203 /** 204 * Function to test if a photo already exists 205 * @param image the image to test 206 * @return true if the photo exists 207 * @throws JiwigoException 208 */ 209 private boolean exists(Image image) throws JiwigoException { 210 try { 211 String imageMD5 = Tools.getMD5Checksum(image.getOriginale().getAbsolutePath()); 212 Document docResult = sessionManager.executeReturnDocument(MethodsEnum.IMAGE_EXIST.getLabel(), 213 "md5sum_list", imageMD5); 214 String result = Tools.getStringValueDom(docResult.getDocumentElement(), imageMD5); 215 216 if (result != null && !"".equals(result)) { 217 return true; 218 } else { 219 return false; 220 } 221 } catch (NoSuchAlgorithmException e) { 222 throw new JiwigoException(e); 223 } catch (IOException e) { 224 throw new JiwigoException(e); 225 } 198 226 } 199 227 … … 279 307 } 280 308 281 public void addSimple(File file, Integer category, String title ) throws JiwigoException {309 public void addSimple(File file, Integer category, String title, Integer level) throws JiwigoException { 282 310 HttpPost httpMethod = new HttpPost(((SessionManagerImpl) sessionManager).getUrl()); 283 311 … … 299 327 multipartEntity.addPart("category", new StringBody(category.toString())); 300 328 multipartEntity.addPart("name", new StringBody(title)); 329 if (level != null) { 330 multipartEntity.addPart("level", new StringBody(level.toString())); 331 } 301 332 } catch (UnsupportedEncodingException e) { 302 333 throw new JiwigoException(e);
Note: See TracChangeset
for help on using the changeset viewer.