Changeset 10716
- Timestamp:
- May 1, 2011, 12:44:59 PM (13 years ago)
- Location:
- extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/ImageDao.java
r10505 r10716 82 82 public void addSimple(File file, Integer category, String title) throws JiwigoException; 83 83 84 /** 85 * Deletes an image 86 * @param image the image to delete 87 * @throws JiwigoException 88 */ 89 public boolean delete(Image image) throws JiwigoException; 90 84 91 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/CategoryDaoImpl.java
r10714 r10716 116 116 public boolean delete(Category category) throws JiwigoException { 117 117 //this document will allow to get pwg_token. it is necessary to delete a category 118 Document docStatus = sessionManager.executeReturnDocument(MethodsEnum.SESSION_STATUS.getLabel()); 119 String pwgToken = Tools.getStringValueDom(docStatus.getDocumentElement(), "pwg_token"); 120 if (pwgToken.equals("")) { 121 throw new JiwigoException("Error getting pwg_token. Returned document was : " 122 + Tools.documentToString(docStatus)); 118 String pwgToken = sessionManager.getPwgToken(); 119 if (pwgToken == null) { 120 throw new JiwigoException("Error : received a null pwg_token"); 123 121 } 124 122 if (LOG.isDebugEnabled()) { -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/ImageDaoImpl.java
r10714 r10716 356 356 } 357 357 358 /** 359 * @see fr.mael.jiwigo.dao.ImageDao#delete(fr.mael.jiwigo.om.Image) 360 */ 361 public boolean delete(Image image) throws JiwigoException { 362 //this document will allow to get pwg_token. it is necessary to delete an image 363 String pwgToken = sessionManager.getPwgToken(); 364 if (pwgToken == null) { 365 throw new JiwigoException("Error : received a null pwg_token"); 366 } 367 if (LOG.isDebugEnabled()) { 368 LOG.debug("Deletes image " + image.getIdentifier() + " with pwg_token = " + pwgToken); 369 } 370 371 Document doc = sessionManager.executeReturnDocument(MethodsEnum.DELETE_IMAGE.getLabel(), "image_id", 372 String.valueOf(image.getIdentifier()), "pwg_token", pwgToken); 373 374 if (LOG.isDebugEnabled()) { 375 LOG.debug(Tools.documentToString(doc)); 376 } 377 try { 378 return Tools.checkOk(doc); 379 } catch (FileAlreadyExistsException e) { 380 e.printStackTrace(); 381 } 382 return false; 383 384 } 385 358 386 public SessionManager getSessionManager() { 359 387 return sessionManager; … … 363 391 this.sessionManager = sessionManager; 364 392 } 393 365 394 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/ImageService.java
r10505 r10716 40 40 public boolean create(String filePath, Integer idCategory, Integer originalWidth, Integer originalHeight, 41 41 Double chunckSize, Integer privacyLevel) throws IOException, NoSuchAlgorithmException, 42 FileAlreadyExistsException, ProxyAuthenticationException, WrongChunkSizeException, 43 JiwigoException; 42 FileAlreadyExistsException, ProxyAuthenticationException, WrongChunkSizeException, JiwigoException; 44 43 45 44 /** … … 74 73 public void addSimple(File file, Integer category, String title) throws JiwigoException; 75 74 75 /** 76 * Deletes an image 77 * @param image the image to delete 78 * @throws JiwigoException 79 */ 80 public boolean delete(Image image) throws JiwigoException; 81 76 82 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/impl/ImageServiceImpl.java
r10505 r10716 73 73 public boolean create(String filePath, Integer idCategory, Integer originalWidth, Integer originalHeight, 74 74 Double chunckSize, Integer privacyLevel) throws IOException, NoSuchAlgorithmException, 75 FileAlreadyExistsException, ProxyAuthenticationException, WrongChunkSizeException, 76 JiwigoException { 75 FileAlreadyExistsException, ProxyAuthenticationException, WrongChunkSizeException, JiwigoException { 77 76 File originalFile = new File(filePath); 78 77 //get the byte array of the original file, to keep metadata … … 151 150 } 152 151 152 public boolean delete(Image image) throws JiwigoException { 153 if (image.getIdentifier() == null) { 154 throw new JiwigoException("The identifier of the image cannot be null"); 155 } else { 156 return dao.delete(image); 157 } 158 159 } 160 153 161 public ImageDao getDao() { 154 162 return dao; -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/enumeration/MethodsEnum.java
r10714 r10716 28 28 "pwg.images.setInfo"), SEARCH("pwg.images.search"), SET_PRIVACY_LEVEL("pwg.images.setPrivacyLevel"), ADD_SIMPLE( 29 29 "pwg.images.addSimple"), ADD_IMAGE("pwg.images.add"), ADD_CHUNK("pwg.images.addChunk"), DELETE_CATEGORY( 30 "pwg.categories.delete"), SESSION_STATUS("pwg.session.getStatus");30 "pwg.categories.delete"), DELETE_IMAGE("pwg.images.delete"), SESSION_STATUS("pwg.session.getStatus"); 31 31 32 32 protected String label; -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/SessionManager.java
r10698 r10716 127 127 */ 128 128 public InputStream getInputStreamFromUrl(String url) throws Exception; 129 130 /** 131 * This method allows to get pwg_token. This string is necessary 132 * to call web service functions like pwg.images.delete and pwg.categories.delete 133 * @return pwg_token 134 */ 135 public String getPwgToken() throws JiwigoException; 136 129 137 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/impl/SessionManagerImpl.java
r10714 r10716 266 266 267 267 /** 268 * @see fr.mael.jiwigo.transverse.session.SessionManager#getPwgToken() 269 */ 270 public String getPwgToken() throws JiwigoException { 271 Document docStatus = executeReturnDocument(MethodsEnum.SESSION_STATUS.getLabel()); 272 String pwgToken = Tools.getStringValueDom(docStatus.getDocumentElement(), "pwg_token"); 273 if ("".equals(pwgToken)) { 274 throw new JiwigoException("Error getting pwg_token. Returned document was : " 275 + Tools.documentToString(docStatus)); 276 } 277 return pwgToken; 278 } 279 280 /** 268 281 * @return the login 269 282 */
Note: See TracChangeset
for help on using the changeset viewer.