Changeset 10714
- Timestamp:
- May 1, 2011, 12:19:10 PM (14 years ago)
- Location:
- extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CategoryDao.java
r10505 r10714 28 28 */ 29 29 public boolean create(Category category) throws JiwigoException; 30 31 /** 32 * Function that deletes a given category 33 * @param category the category to delete 34 * @return true if the category is successfully deleted 35 * @throws JiwigoException 36 */ 37 public boolean delete(Category category) throws JiwigoException; 30 38 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/CategoryDaoImpl.java
r10505 r10714 111 111 } 112 112 113 /** 114 * @see fr.mael.jiwigo.dao.CategoryDao#delete(fr.mael.jiwigo.om.Category) 115 */ 116 public boolean delete(Category category) throws JiwigoException { 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)); 123 } 124 if (LOG.isDebugEnabled()) { 125 LOG.debug("Deletes category " + category.getIdentifier() + " with pwg_token = " + pwgToken); 126 } 127 128 Document doc = sessionManager.executeReturnDocument(MethodsEnum.DELETE_CATEGORY.getLabel(), "category_id", 129 String.valueOf(category.getIdentifier()), "pwg_token", pwgToken); 130 131 if (LOG.isDebugEnabled()) { 132 LOG.debug(Tools.documentToString(doc)); 133 } 134 try { 135 return Tools.checkOk(doc); 136 } catch (FileAlreadyExistsException e) { 137 e.printStackTrace(); 138 } 139 return false; 140 } 141 113 142 public SessionManager getSessionManager() { 114 143 return sessionManager; -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/ImageDaoImpl.java
r10704 r10714 146 146 String thumbnailBase64 = base64.encode(Tools.getBytesFromFile(image.getThumbnail())); 147 147 //sends the thumbnail and gets the result 148 Document reponseThumb = (sessionManager.executeReturnDocument( "pwg.images.addChunk", "data", thumbnailBase64,149 "type", "thumb", "position", "1", "original_sum",148 Document reponseThumb = (sessionManager.executeReturnDocument(MethodsEnum.ADD_CHUNK.getLabel(), "data", 149 thumbnailBase64, "type", "thumb", "position", "1", "original_sum", 150 150 Tools.getMD5Checksum(image.getOriginale().getAbsolutePath()))); 151 151 … … 160 160 File fichierAEnvoyer = filesToSend.get(i); 161 161 String originaleBase64 = base64.encode(Tools.getBytesFromFile(fichierAEnvoyer)); 162 Document reponseOriginale = (sessionManager.executeReturnDocument( "pwg.images.addChunk", "data",162 Document reponseOriginale = (sessionManager.executeReturnDocument(MethodsEnum.ADD_CHUNK.getLabel(), "data", 163 163 originaleBase64, "type", "file", "position", String.valueOf(i), "original_sum", 164 164 Tools.getMD5Checksum(image.getOriginale().getAbsolutePath()))); … … 171 171 172 172 //add the image in the database and get the result of the webservice 173 Document reponseAjout = (sessionManager.executeReturnDocument( "pwg.images.add", "file_sum",173 Document reponseAjout = (sessionManager.executeReturnDocument(MethodsEnum.ADD_IMAGE.getLabel(), "file_sum", 174 174 Tools.getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum", 175 175 Tools.getMD5Checksum(image.getThumbnail().getCanonicalPath()), "position", "1", "original_sum", … … 177 177 String.valueOf(image.getIdCategory()), "name", image.getName(), "author", sessionManager.getLogin(), 178 178 "level", image.getPrivacyLevel())); 179 LOG.debug("Response add : " + Tools.documentToString(reponseAjout)); 179 if (LOG.isDebugEnabled()) { 180 LOG.debug("Response add : " + Tools.documentToString(reponseAjout)); 181 } 180 182 // System.out.println(Main.sessionManager.executerReturnString("pwg.images.add", "file_sum", Outil 181 183 // .getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum", Outil.getMD5Checksum(image … … 294 296 // string.lastIndexOf("}") + 1); 295 297 try { 296 multipartEntity.addPart("method", new StringBody( "pwg.images.addSimple"));298 multipartEntity.addPart("method", new StringBody(MethodsEnum.ADD_SIMPLE.getLabel())); 297 299 multipartEntity.addPart("category", new StringBody(category.toString())); 298 300 multipartEntity.addPart("name", new StringBody(title)); -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/TagDaoImpl.java
r10700 r10714 55 55 public List<Tag> list() throws JiwigoException { 56 56 Document doc = sessionManager.executeReturnDocument(MethodsEnum.TAGS_ADMIN_LIST.getLabel()); 57 // System.out.println(Outil.documentToString(doc));58 NodeList nodeList = doc.getDocumentElement().getElementsByTagName("tags");59 57 return getTagsFromDocument((Element) doc.getDocumentElement().getElementsByTagName("tags").item(0)); 60 58 -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/CategoryService.java
r10505 r10714 42 42 */ 43 43 public boolean create(String nom) throws JiwigoException; 44 45 /** 46 * Deletes a category 47 * @param id id of the category 48 * @return 49 * @throws JiwigoException 50 */ 51 public boolean delete(Category category) throws JiwigoException; 44 52 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/impl/CategoryServiceImpl.java
r10505 r10714 107 107 } 108 108 109 public boolean delete(Category category) throws JiwigoException { 110 if (category.getIdentifier() == null) { 111 throw new JiwigoException("The identifier of the category cannot be null"); 112 } else { 113 return dao.delete(category); 114 } 115 } 116 109 117 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/enumeration/MethodsEnum.java
r9879 r10714 26 26 "pwg.images.getInfo"), AJOUTER_CATEGORIE("pwg.categories.add"), AJOUTER_COMMENTAIRE("pwg.images.addComment"), LISTER_TAGS( 27 27 "pwg.tags.getList"), TAGS_ADMIN_LIST("pwg.tags.getAdminList"), ADD_TAG("pwg.tags.add"), SET_INFO( 28 "pwg.images.setInfo"), SEARCH("pwg.images.search"), SET_PRIVACY_LEVEL("pwg.images.setPrivacyLevel"); 28 "pwg.images.setInfo"), SEARCH("pwg.images.search"), SET_PRIVACY_LEVEL("pwg.images.setPrivacyLevel"), ADD_SIMPLE( 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"); 29 31 30 32 protected String label; -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/impl/SessionManagerImpl.java
r10698 r10714 161 161 } 162 162 doc = executeReturnDocument(MethodsEnum.LOGIN.getLabel(), "username", login, "password", password); 163 if (LOG.isDebugEnabled()) { 164 LOG.debug("XML connection : " + Tools.documentToString(doc)); 165 } 163 166 try { 164 167 return (Tools.checkOk(doc) ? 0 : 1); -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/Tools.java
r10090 r10714 229 229 return true; 230 230 } else { 231 LOG.error("Resultat : " + doc.getDocumentElement().getAttribute("stat") + "\nDocument retourn é: \n"231 LOG.error("Resultat : " + doc.getDocumentElement().getAttribute("stat") + "\nDocument retourne : \n" 232 232 + Tools.documentToString(doc)); 233 233 if (((Element) doc.getDocumentElement().getElementsByTagName("err").item(0)).getAttribute("msg").equals( … … 352 352 Element el = (Element) element.getElementsByTagName(tagName).item(0); 353 353 if (el != null) { 354 354 return el.getFirstChild().getNodeValue(); 355 355 } 356 356 // if not, empty string is safer then null
Note: See TracChangeset
for help on using the changeset viewer.