Changeset 9392 for extensions/jiwigo-ws-api
- Timestamp:
- Feb 27, 2011, 1:38:04 PM (13 years ago)
- Location:
- extensions/jiwigo-ws-api
- Files:
-
- 17 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo-ws-api/.classpath
r9387 r9392 7 7 <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar"/> 8 8 <classpathentry kind="var" path="M2_REPO/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar"/> 9 <classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"/> 9 10 <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.2/commons-codec-1.2.jar"/> 10 11 <classpathentry kind="var" path="M2_REPO/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar"/> 11 12 <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5.jar"/> 12 13 <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/> 13 <classpathentry kind="var" path="M2_REPO/net/iharder/filedrop/1.0/filedrop-1.0.jar"/>14 <classpathentry kind="var" path="M2_REPO/com/jhlabs/filters/2.0.235/filters-2.0.235.jar"/>15 14 <classpathentry kind="var" path="M2_REPO/org/jdom/jdom/1.1/jdom-1.1.jar"/> 16 15 <classpathentry kind="var" path="M2_REPO/junit/junit/4.8.1/junit-4.8.1.jar"/> … … 19 18 <classpathentry kind="var" path="M2_REPO/com/drew/metadata-extractor/2.3.1/metadata-extractor-2.3.1.jar"/> 20 19 <classpathentry kind="var" path="M2_REPO/org/apache/sanselan/sanselan/0.97-incubator/sanselan-0.97-incubator.jar"/> 21 <classpathentry kind="var" path="M2_REPO/org/swinglabs/swing-worker/1.1/swing-worker-1.1.jar"/>22 <classpathentry kind="var" path="M2_REPO/org/swinglabs/swingx/1.6.1/swingx-1.6.1.jar"/>23 20 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 24 21 </classpath> -
extensions/jiwigo-ws-api/.project
r9387 r9392 1 <?xml version="1.0" encoding="UTF-8"?>2 1 <projectDescription> 3 <name>jiwigo-ws-api</name> 4 <comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment> 5 <projects> 6 </projects> 7 <buildSpec> 8 <buildCommand> 9 <name>org.eclipse.jdt.core.javabuilder</name> 10 <arguments> 11 </arguments> 12 </buildCommand> 13 <buildCommand> 14 <name>org.maven.ide.eclipse.maven2Builder</name> 15 <arguments> 16 </arguments> 17 </buildCommand> 18 </buildSpec> 19 <natures> 20 <nature>org.maven.ide.eclipse.maven2Nature</nature> 21 <nature>org.eclipse.jdt.core.javanature</nature> 22 </natures> 2 <name>jiwigo-ws-api</name> 3 <comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment> 4 <projects/> 5 <buildSpec> 6 <buildCommand> 7 <name>org.eclipse.jdt.core.javabuilder</name> 8 </buildCommand> 9 <buildCommand> 10 <name>org.maven.ide.eclipse.maven2Builder</name> 11 </buildCommand> 12 </buildSpec> 13 <natures> 14 <nature>org.maven.ide.eclipse.maven2Nature</nature> 15 <nature>org.eclipse.jdt.core.javanature</nature> 16 </natures> 23 17 </projectDescription> -
extensions/jiwigo-ws-api/pom.xml
r9387 r9392 3 3 <groupId>fr.mael.jiwigo</groupId> 4 4 <artifactId>jiwigo-ws-api</artifactId> 5 <version>0.13 </version>5 <version>0.13.1</version> 6 6 7 7 … … 50 50 <version>4.8.1</version> 51 51 </dependency> 52 <dependency> 53 <groupId>commons-beanutils</groupId> 54 <artifactId>commons-beanutils</artifactId> 55 <version>1.8.3</version> 56 </dependency> 52 57 53 58 </dependencies> -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CategoryDao.java
r9387 r9392 12 12 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 13 13 import fr.mael.jiwigo.transverse.session.SessionManager; 14 import fr.mael.jiwigo.transverse.util. Outil;14 import fr.mael.jiwigo.transverse.util.Tools; 15 15 16 16 /* … … 78 78 /** 79 79 * Lists the categories 80 * @param rafraichir true : uses the categories of the cache81 80 * @param recursive true : recursive listing of the categories 82 81 * @return the list of categories 83 82 * @throws IOException 84 83 */ 85 public List<Category> list er(boolean recursive) throws IOException {86 Document doc = sessionManager.execute rReturnDocument(MethodsEnum.LISTER_CATEGORIES.getLabel(), "recursive",84 public List<Category> list(boolean recursive) throws IOException { 85 Document doc = sessionManager.executeReturnDocument(MethodsEnum.LISTER_CATEGORIES.getLabel(), "recursive", 87 86 String.valueOf(recursive)); 88 87 Element element = doc.getRootElement().getChild("categories"); … … 91 90 for (Element cat : listElement) { 92 91 Category myCat = new Category(); 93 myCat.setIdentifi ant(Integer.valueOf(cat.getAttributeValue(CategoryEnum.ID.getLabel())));92 myCat.setIdentifier(Integer.valueOf(cat.getAttributeValue(CategoryEnum.ID.getLabel()))); 94 93 myCat.setUrlCategory(cat.getAttributeValue(CategoryEnum.URL.getLabel())); 95 94 myCat.setNbImages(Integer.valueOf(cat.getAttributeValue(CategoryEnum.NB_IMAGES.getLabel()))); 96 95 myCat.setNbTotalImages(Integer.valueOf(cat.getAttributeValue(CategoryEnum.NB_TOTAL_IMAGES.getLabel()))); 97 myCat.setN om(cat.getChildText(CategoryEnum.NAME.getLabel()));96 myCat.setName(cat.getChildText(CategoryEnum.NAME.getLabel())); 98 97 String catMeres = cat.getChildText(CategoryEnum.CAT_MERES.getLabel()); 99 98 ArrayList<Integer> idCategoriesMeres = new ArrayList<Integer>(); … … 103 102 } 104 103 } 105 myCat.setId CategoriesMeres(idCategoriesMeres);104 myCat.setIdParentCategories(idCategoriesMeres); 106 105 categories.add(myCat); 107 106 } … … 114 113 * @return true if the category is successfully created 115 114 */ 116 public boolean cre er(Category category) {115 public boolean create(Category category) { 117 116 try { 118 if (category.get ParentDirect() != null) {119 return Outil.checkOk(sessionManager.executerReturnDocument(MethodsEnum.AJOUTER_CATEGORIE.getLabel(),120 "name", category.getN om(), "parent", String.valueOf(category.getParentDirect())));117 if (category.getDirectParent() != null) { 118 return Tools.checkOk(sessionManager.executeReturnDocument(MethodsEnum.AJOUTER_CATEGORIE.getLabel(), 119 "name", category.getName(), "parent", String.valueOf(category.getDirectParent()))); 121 120 } else { 122 return Outil.checkOk(sessionManager.executerReturnDocument(MethodsEnum.AJOUTER_CATEGORIE.getLabel(),123 "name", category.getN om()));121 return Tools.checkOk(sessionManager.executeReturnDocument(MethodsEnum.AJOUTER_CATEGORIE.getLabel(), 122 "name", category.getName())); 124 123 } 125 124 } catch (IOException e) { 126 LOG.error( Outil.getStackTrace(e));125 LOG.error(Tools.getStackTrace(e)); 127 126 } 128 127 return false; -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CommentDao.java
r9387 r9392 11 11 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 12 12 import fr.mael.jiwigo.transverse.session.SessionManager; 13 import fr.mael.jiwigo.transverse.util. Outil;13 import fr.mael.jiwigo.transverse.util.Tools; 14 14 15 15 /* … … 81 81 * @throws IOException 82 82 */ 83 public List<Comment> list er(Integer idImage) throws IOException {84 Document doc = (sessionManager.execute rReturnDocument(MethodsEnum.GET_INFO.getLabel(), "image_id", String83 public List<Comment> list(Integer idImage) throws IOException { 84 Document doc = (sessionManager.executeReturnDocument(MethodsEnum.GET_INFO.getLabel(), "image_id", String 85 85 .valueOf(idImage))); 86 86 Element element = doc.getRootElement().getChild("image").getChild("comments"); … … 89 89 for (Element com : listElement) { 90 90 Comment myCom = new Comment(); 91 myCom.setIdentifi ant(Integer.valueOf(com.getAttributeValue("id")));91 myCom.setIdentifier(Integer.valueOf(com.getAttributeValue("id"))); 92 92 myCom.setDate(com.getAttributeValue("date")); 93 93 myCom.setAuthor(com.getChildText("author")); … … 105 105 */ 106 106 public String getKey(Integer idImage) throws IOException { 107 Document doc = (sessionManager.execute rReturnDocument(MethodsEnum.GET_INFO.getLabel(), "image_id", String107 Document doc = (sessionManager.executeReturnDocument(MethodsEnum.GET_INFO.getLabel(), "image_id", String 108 108 .valueOf(idImage))); 109 109 String key = doc.getRootElement().getChild("image").getChild("comment_post").getAttributeValue("key"); … … 117 117 * @throws IOException 118 118 */ 119 public boolean cre er(Comment commentaire) throws IOException {119 public boolean create(Comment commentaire) throws IOException { 120 120 String key = getKey(commentaire.getImageId()); 121 121 try { … … 124 124 e.printStackTrace(); 125 125 } 126 return Outil.checkOk(sessionManager.executerReturnDocument(MethodsEnum.AJOUTER_COMMENTAIRE.getLabel(),126 return Tools.checkOk(sessionManager.executeReturnDocument(MethodsEnum.AJOUTER_COMMENTAIRE.getLabel(), 127 127 "image_id", String.valueOf(commentaire.getImageId()), "author", commentaire.getAuthor(), "content", 128 128 commentaire.getContent(), "key", key)); -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/ImageDao.java
r9387 r9392 15 15 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 16 16 import fr.mael.jiwigo.transverse.session.SessionManager; 17 import fr.mael.jiwigo.transverse.util. Outil;17 import fr.mael.jiwigo.transverse.util.Tools; 18 18 19 19 /* … … 97 97 * @throws IOException 98 98 */ 99 public List<Image> list er(boolean rafraichir) throws IOException {100 return list erParCategory(null, rafraichir);99 public List<Image> list(boolean refresh) throws IOException { 100 return listByCategory(null, refresh); 101 101 } 102 102 … … 107 107 * @throws IOException 108 108 */ 109 public List<Image> list erParCategory(Integer categoryId, boolean rafraichir) throws IOException {110 if (r afraichir|| cache.get(categoryId) == null) {109 public List<Image> listByCategory(Integer categoryId, boolean refresh) throws IOException { 110 if (refresh || cache.get(categoryId) == null) { 111 111 Document doc = null; 112 112 113 113 if (categoryId != null) { 114 doc = sessionManager.execute rReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel(), "cat_id", String114 doc = sessionManager.executeReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel(), "cat_id", String 115 115 .valueOf(categoryId)); 116 116 } else { 117 doc = sessionManager.execute rReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel());117 doc = sessionManager.executeReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel()); 118 118 } 119 119 Element element = doc.getRootElement().getChild("images"); … … 140 140 * Finally, the response of the webservice is checked 141 141 * 142 * @param the image to create142 * @param image the image to create 143 143 * @return true if the creation of the image was the successful 144 144 * @throws Exception 145 145 */ 146 //TODO ne pas continuer si une des r éponses précédentes est négative147 public boolean cre er(Image image, Double chunkSize) throws Exception {146 //TODO ne pas continuer si une des reponses precedentes est negative 147 public boolean create(Image image, Double chunkSize) throws Exception { 148 148 //thumbnail converted to base64 149 149 BASE64Encoder base64 = new BASE64Encoder(); 150 150 151 String thumbnailBase64 = base64.encode( Outil.getBytesFromFile(image.getThumbnail()));151 String thumbnailBase64 = base64.encode(Tools.getBytesFromFile(image.getThumbnail())); 152 152 //sends the thumbnail and gets the result 153 Document reponseThumb = (sessionManager.execute rReturnDocument("pwg.images.addChunk", "data", thumbnailBase64,154 "type", "thumb", "position", "1", "original_sum", Outil.getMD5Checksum(image.getOriginale()153 Document reponseThumb = (sessionManager.executeReturnDocument("pwg.images.addChunk", "data", thumbnailBase64, 154 "type", "thumb", "position", "1", "original_sum", Tools.getMD5Checksum(image.getOriginale() 155 155 .getAbsolutePath()))); 156 156 157 157 //begin feature:0001827 158 158 int chunk = chunkSize.intValue(); 159 ArrayList<File> fichiersAEnvoyer = Outil.splitFile(image.getOriginale(), chunk);159 ArrayList<File> fichiersAEnvoyer = Tools.splitFile(image.getOriginale(), chunk); 160 160 boolean echec = false; 161 161 for (int i = 0; i < fichiersAEnvoyer.size(); i++) { 162 162 File fichierAEnvoyer = fichiersAEnvoyer.get(i); 163 String originaleBase64 = base64.encode( Outil.getBytesFromFile(fichierAEnvoyer));164 Document reponseOriginale = (sessionManager.execute rReturnDocument("pwg.images.addChunk", "data",165 originaleBase64, "type", "file", "position", String.valueOf(i), "original_sum", Outil163 String originaleBase64 = base64.encode(Tools.getBytesFromFile(fichierAEnvoyer)); 164 Document reponseOriginale = (sessionManager.executeReturnDocument("pwg.images.addChunk", "data", 165 originaleBase64, "type", "file", "position", String.valueOf(i), "original_sum", Tools 166 166 .getMD5Checksum(image.getOriginale().getAbsolutePath()))); 167 if (! Outil.checkOk(reponseOriginale)) {167 if (!Tools.checkOk(reponseOriginale)) { 168 168 echec = true; 169 169 break; … … 173 173 174 174 //add the image in the database and get the result of the webservice 175 Document reponseAjout = (sessionManager.execute rReturnDocument("pwg.images.add", "file_sum", Outil176 .getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum", Outil.getMD5Checksum(image177 .getThumbnail().getCanonicalPath()), "position", "1", "original_sum", Outil.getMD5Checksum(image175 Document reponseAjout = (sessionManager.executeReturnDocument("pwg.images.add", "file_sum", Tools 176 .getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum", Tools.getMD5Checksum(image 177 .getThumbnail().getCanonicalPath()), "position", "1", "original_sum", Tools.getMD5Checksum(image 178 178 .getOriginale().getAbsolutePath()), "categories", String.valueOf(image.getIdCategory()), "name", image 179 179 .getName(), "author", sessionManager.getLogin(), "level", image.getPrivacyLevel())); 180 LOG.debug("Response add : " + Outil.documentToString(reponseAjout));180 LOG.debug("Response add : " + Tools.documentToString(reponseAjout)); 181 181 // System.out.println(Main.sessionManager.executerReturnString("pwg.images.add", "file_sum", Outil 182 182 // .getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum", Outil.getMD5Checksum(image … … 189 189 // } 190 190 boolean reussite = true; 191 if (! Outil.checkOk(reponseThumb) || echec || !Outil.checkOk(reponseAjout)) {191 if (!Tools.checkOk(reponseThumb) || echec || !Tools.checkOk(reponseAjout)) { 192 192 reussite = false; 193 193 } 194 suppressionFichierTemporaires();194 deleteTempFiles(); 195 195 return reussite; 196 196 … … 204 204 */ 205 205 public boolean addTags(Integer imageId, String tagId) throws IOException { 206 Document doc = sessionManager.execute rReturnDocument(MethodsEnum.SET_INFO.getLabel(), "image_id", String206 Document doc = sessionManager.executeReturnDocument(MethodsEnum.SET_INFO.getLabel(), "image_id", String 207 207 .valueOf(imageId), "tag_ids", tagId); 208 return Outil.checkOk(doc);208 return Tools.checkOk(doc); 209 209 210 210 } … … 220 220 for (Element im : listElement) { 221 221 Image myImage = new Image(); 222 myImage.set Miniature(im.getAttributeValue("tn_url"));222 myImage.setThumbnailUrl(im.getAttributeValue("tn_url")); 223 223 myImage.setUrl(im.getAttributeValue("element_url")); 224 224 myImage.setWidth(Integer.valueOf(im.getAttributeValue("width"))); 225 225 myImage.setHeight(Integer.valueOf(im.getAttributeValue("height"))); 226 226 myImage.setFile(im.getAttributeValue("file")); 227 myImage.set Vue(Integer.valueOf(im.getAttributeValue("hit")));228 myImage.setIdentifi ant(Integer.valueOf(im.getAttributeValue("id")));227 myImage.setSeen(Integer.valueOf(im.getAttributeValue("hit"))); 228 myImage.setIdentifier(Integer.valueOf(im.getAttributeValue("id"))); 229 229 myImage.setName(im.getChildText("name")); 230 230 System.out.println(new XMLOutputter().outputString(im)); … … 246 246 */ 247 247 public List<Image> search(String searchString) throws IOException { 248 Document doc = sessionManager.execute rReturnDocument(MethodsEnum.SEARCH.getLabel(), "query", searchString);248 Document doc = sessionManager.executeReturnDocument(MethodsEnum.SEARCH.getLabel(), "query", searchString); 249 249 LOG.debug(doc); 250 250 Element element = doc.getRootElement().getChild("images"); … … 253 253 } 254 254 255 private void suppressionFichierTemporaires() {255 private void deleteTempFiles() { 256 256 File file = new File(System.getProperty("java.io.tmpdir") + "/originale.jpg"); 257 257 file.delete(); -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/TagDao.java
r9387 r9392 13 13 import fr.mael.jiwigo.transverse.enumeration.TagEnum; 14 14 import fr.mael.jiwigo.transverse.session.SessionManager; 15 import fr.mael.jiwigo.transverse.util.Outil; 16 /* 17 Copyright (c) 2010, Mael 18 All rights reserved. 19 20 Redistribution and use in source and binary forms, with or without 21 modification, are permitted provided that the following conditions are met: 22 * Redistributions of source code must retain the above copyright 23 notice, this list of conditions and the following disclaimer. 24 * Redistributions in binary form must reproduce the above copyright 25 notice, this list of conditions and the following disclaimer in the 26 documentation and/or other materials provided with the distribution. 27 * Neither the name of jiwigo nor the 28 names of its contributors may be used to endorse or promote products 29 derived from this software without specific prior written permission. 30 31 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 32 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 33 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 34 DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY 35 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 36 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 37 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 38 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 40 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 */ 42 15 import fr.mael.jiwigo.transverse.util.Tools; 43 16 44 17 /** … … 81 54 * @throws IOException 82 55 */ 83 public List<Tag> list er() throws IOException {84 Document doc = sessionManager.execute rReturnDocument(MethodsEnum.TAGS_ADMIN_LIST.getLabel());56 public List<Tag> list() throws IOException { 57 Document doc = sessionManager.executeReturnDocument(MethodsEnum.TAGS_ADMIN_LIST.getLabel()); 85 58 // System.out.println(Outil.documentToString(doc)); 86 59 return getTagsFromDocument(doc.getRootElement().getChild("tags")); … … 99 72 for (Element tagElement : listElement) { 100 73 Tag tag = new Tag(); 101 tag.setId (Integer.valueOf(tagElement.getAttributeValue(TagEnum.ID.getLabel())));102 tag.setN om(tagElement.getAttributeValue(TagEnum.NAME.getLabel()));74 tag.setIdentifier(Integer.valueOf(tagElement.getAttributeValue(TagEnum.ID.getLabel()))); 75 tag.setName(tagElement.getAttributeValue(TagEnum.NAME.getLabel())); 103 76 tags.add(tag); 104 77 } … … 112 85 * @return true if the tag as been successfully created 113 86 */ 114 public boolean cre er(Tag tag) {87 public boolean create(Tag tag) { 115 88 try { 116 return Outil.checkOk(sessionManager.executerReturnDocument(MethodsEnum.ADD_TAG.getLabel(), "name", tag117 .getN om()));89 return Tools.checkOk(sessionManager.executeReturnDocument(MethodsEnum.ADD_TAG.getLabel(), "name", tag 90 .getName())); 118 91 } catch (IOException e) { 119 LOG.error( Outil.getStackTrace(e));92 LOG.error(Tools.getStackTrace(e)); 120 93 } 121 94 return false; … … 129 102 */ 130 103 public List<Tag> tagsForImage(Image image) throws IOException { 131 Document doc = sessionManager.execute rReturnDocument(MethodsEnum.GET_INFO.getLabel(), "image_id", String132 .valueOf(image.getIdentifi ant()));104 Document doc = sessionManager.executeReturnDocument(MethodsEnum.GET_INFO.getLabel(), "image_id", String 105 .valueOf(image.getIdentifier())); 133 106 return getTagsFromDocument(doc.getRootElement().getChild("image").getChild("tags")); 134 107 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/om/Category.java
r9387 r9392 38 38 public class Category { 39 39 40 private ArrayList<Integer> id CategoriesMeres;41 private Integer identifi ant;40 private ArrayList<Integer> idParentCategories; 41 private Integer identifier; 42 42 private String urlCategory; 43 43 private Integer nbImages; 44 44 private Integer nbTotalImages; 45 private ArrayList<Category> c ategoriesFilles;46 private ArrayList<Category> categoriesMeres;47 private String n om;45 private ArrayList<Category> childCategories; 46 private ArrayList<Category> parentCategories; 47 private String name; 48 48 private Element element; 49 private Integer parentDirect;49 private Integer directParent; 50 50 private Integer level; 51 51 52 52 public Category() { 53 c ategoriesFilles = new ArrayList<Category>();54 categoriesMeres = new ArrayList<Category>();53 childCategories = new ArrayList<Category>(); 54 parentCategories = new ArrayList<Category>(); 55 55 } 56 56 57 57 @Override 58 58 public String toString() { 59 return nom; 60 } 61 62 /** 63 * @return the idCategoriesMeres 64 */ 65 public ArrayList<Integer> getIdCategoriesMeres() { 66 return idCategoriesMeres; 67 } 68 69 /** 70 * @param idCategoriesMeres the idCategoriesMeres to set 71 */ 72 public void setIdCategoriesMeres(ArrayList<Integer> idCategoriesMeres) { 73 this.idCategoriesMeres = idCategoriesMeres; 74 } 75 76 /** 77 * @return the identifiant 78 */ 79 public Integer getIdentifiant() { 80 return identifiant; 81 } 82 83 /** 84 * @param identifiant the identifiant to set 85 */ 86 public void setIdentifiant(Integer identifiant) { 87 this.identifiant = identifiant; 59 return name; 88 60 } 89 61 … … 131 103 132 104 /** 133 * @return the categoriesFilles134 */135 public ArrayList<Category> getCategoriesFilles() {136 return categoriesFilles;137 }138 139 /**140 * @param categoriesFilles the categoriesFilles to set141 */142 public void setCategoriesFilles(ArrayList<Category> categoriesFilles) {143 this.categoriesFilles = categoriesFilles;144 }145 146 /**147 * @return the categoriesMeres148 */149 public ArrayList<Category> getCategoriesMeres() {150 return categoriesMeres;151 }152 153 /**154 * @param categoriesMeres the categoriesMeres to set155 */156 public void setCategoriesMeres(ArrayList<Category> categoriesMeres) {157 this.categoriesMeres = categoriesMeres;158 }159 160 /**161 * @return the nom162 */163 public String getNom() {164 return nom;165 }166 167 /**168 * @param nom the nom to set169 */170 public void setNom(String nom) {171 this.nom = nom;172 }173 174 /**175 105 * @return the element 176 106 */ … … 186 116 } 187 117 188 /**189 * @return the parentDirect190 */191 public Integer getParentDirect() {192 return parentDirect;193 }194 195 /**196 * @param parentDirect the parentDirect to set197 */198 public void setParentDirect(Integer parentDirect) {199 this.parentDirect = parentDirect;200 }201 202 118 public Integer getLevel() { 203 119 return level; … … 208 124 } 209 125 126 public ArrayList<Integer> getIdParentCategories() { 127 return idParentCategories; 128 } 129 130 public void setIdParentCategories(ArrayList<Integer> idParentCategories) { 131 this.idParentCategories = idParentCategories; 132 } 133 134 public Integer getIdentifier() { 135 return identifier; 136 } 137 138 public void setIdentifier(Integer identifier) { 139 this.identifier = identifier; 140 } 141 142 public ArrayList<Category> getChildCategories() { 143 return childCategories; 144 } 145 146 public void setChildCategories(ArrayList<Category> childCategories) { 147 this.childCategories = childCategories; 148 } 149 150 public ArrayList<Category> getParentCategories() { 151 return parentCategories; 152 } 153 154 public void setParentCategories(ArrayList<Category> parentCategories) { 155 this.parentCategories = parentCategories; 156 } 157 158 public String getName() { 159 return name; 160 } 161 162 public void setName(String name) { 163 this.name = name; 164 } 165 166 public Integer getDirectParent() { 167 return directParent; 168 } 169 170 public void setDirectParent(Integer directParent) { 171 this.directParent = directParent; 172 } 173 210 174 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/om/Comment.java
r9387 r9392 37 37 private String content; 38 38 private String key; 39 private Integer identifi ant;39 private Integer identifier; 40 40 private String date; 41 41 … … 96 96 } 97 97 98 /** 99 * @return the identifiant 100 */ 101 public Integer getIdentifiant() { 102 return identifiant; 98 public Integer getIdentifier() { 99 return identifier; 103 100 } 104 101 105 /** 106 * @param identifiant the identifiant to set 107 */ 108 public void setIdentifiant(Integer identifiant) { 109 this.identifiant = identifiant; 102 public void setIdentifier(Integer identifier) { 103 this.identifier = identifier; 110 104 } 111 105 -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/om/Image.java
r9387 r9392 36 36 */ 37 37 public class Image { 38 private String miniature;38 private String thumbnailUrl; 39 39 private String url; 40 40 private Integer width; 41 41 private Integer height; 42 42 private String file; 43 private Integer identifi ant;44 private Integer vue;43 private Integer identifier; 44 private Integer seen; 45 45 private String name; 46 46 private Integer idCategory; 47 private String aut eur;47 private String author; 48 48 private File thumbnail; 49 49 private String privacyLevel; … … 63 63 } 64 64 65 /** 66 * @return the auteur 67 */ 68 public String getAuteur() { 69 return auteur; 70 } 71 72 /** 73 * @param auteur the auteur to set 74 */ 75 public void setAuteur(String auteur) { 76 this.auteur = auteur; 65 public Integer getSeen() { 66 return seen; 67 } 68 69 public void setSeen(Integer seen) { 70 this.seen = seen; 71 } 72 73 public String getAuthor() { 74 return author; 75 } 76 77 public void setAuthor(String author) { 78 this.author = author; 77 79 } 78 80 … … 113 115 } 114 116 115 /** 116 * @return the miniature 117 */ 118 public String getMiniature() { 119 return miniature; 120 } 121 122 /** 123 * @param miniature the miniature to set 124 */ 125 public void setMiniature(String miniature) { 126 this.miniature = miniature; 117 public String getThumbnailUrl() { 118 return thumbnailUrl; 119 } 120 121 public void setThumbnailUrl(String thumbnailUrl) { 122 this.thumbnailUrl = thumbnailUrl; 127 123 } 128 124 … … 183 179 } 184 180 185 /** 186 * @return the identifiant 187 */ 188 public Integer getIdentifiant() { 189 return identifiant; 190 } 191 192 /** 193 * @param identifiant the identifiant to set 194 */ 195 public void setIdentifiant(Integer identifiant) { 196 this.identifiant = identifiant; 197 } 198 199 /** 200 * @return the vue 201 */ 202 public Integer getVue() { 203 return vue; 204 } 205 206 /** 207 * @param vue the vue to set 208 */ 209 public void setVue(Integer vue) { 210 this.vue = vue; 181 public Integer getIdentifier() { 182 return identifier; 183 } 184 185 public void setIdentifier(Integer identifier) { 186 this.identifier = identifier; 211 187 } 212 188 -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/om/Tag.java
r9387 r9392 36 36 * Name of the tag 37 37 */ 38 private String n om;38 private String name; 39 39 40 40 /** 41 41 * Id of the tag 42 42 */ 43 private Integer identifi ant;43 private Integer identifier; 44 44 45 /** 46 * @return the nom 47 */ 48 public String getNom() { 49 return nom; 45 public String getName() { 46 return name; 50 47 } 51 48 52 /** 53 * @param nom the nom to set 54 */ 55 public void setNom(String nom) { 56 this.nom = nom; 49 public void setName(String name) { 50 this.name = name; 57 51 } 58 52 59 /** 60 * @return the id 61 */ 62 public Integer getId() { 63 return identifiant; 53 public Integer getIdentifier() { 54 return identifier; 64 55 } 65 56 66 /** 67 * @param id the id to set 68 */ 69 public void setId(Integer id) { 70 this.identifiant = id; 57 public void setIdentifier(Integer identifier) { 58 this.identifier = identifier; 71 59 } 72 60 … … 74 62 public String toString() { 75 63 // TODO Auto-generated method stub 76 return n om;64 return name; 77 65 } 78 66 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/CategoryService.java
r9387 r9392 73 73 /** 74 74 * Lists all categories 75 * @param rafraichir true to refresh76 75 * @param recursive true : recursive listing 77 76 * @return the list of categories 78 77 * @throws IOException 79 78 */ 80 public List<Category> list er(boolean recursive) throws IOException {81 return CategoryDao.getInstance(sessionManager).list er(recursive);79 public List<Category> list(boolean recursive) throws IOException { 80 return CategoryDao.getInstance(sessionManager).list(recursive); 82 81 } 83 82 … … 88 87 */ 89 88 public List<Category> makeTree() throws IOException { 90 List<Category> list = CategoryDao.getInstance(sessionManager).list er(true);89 List<Category> list = CategoryDao.getInstance(sessionManager).list(true); 91 90 for (Category category : list) { 92 91 for (Category category2 : list) { 93 if (category2.getId CategoriesMeres().size() != 194 && category.getIdentifi ant().equals(95 category2.getId CategoriesMeres().get(category2.getIdCategoriesMeres().size() - 2))) {96 category.getC ategoriesFilles().add(category2);97 category2.get CategoriesMeres().add(category);92 if (category2.getIdParentCategories().size() != 1 93 && category.getIdentifier().equals( 94 category2.getIdParentCategories().get(category2.getIdParentCategories().size() - 2))) { 95 category.getChildCategories().add(category2); 96 category2.getParentCategories().add(category); 98 97 } 99 98 … … 111 110 * @return true if successful 112 111 */ 113 public boolean cre er(String nom, Integer parent) {112 public boolean create(String nom, Integer parent) { 114 113 Category category = new Category(); 115 category.set ParentDirect(parent);116 category.setN om(nom);117 return CategoryDao.getInstance(sessionManager).cre er(category);114 category.setDirectParent(parent); 115 category.setName(nom); 116 return CategoryDao.getInstance(sessionManager).create(category); 118 117 } 119 118 … … 123 122 * @return true if successful 124 123 */ 125 public boolean cre er(String nom) {124 public boolean create(String nom) { 126 125 Category category = new Category(); 127 category.setN om(nom);128 return CategoryDao.getInstance(sessionManager).cre er(category);126 category.setName(nom); 127 return CategoryDao.getInstance(sessionManager).create(category); 129 128 } 130 129 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/CommentService.java
r9387 r9392 76 76 * @throws IOException 77 77 */ 78 public List<Comment> list er(Integer imageId) throws IOException {79 return CommentDao.getInstance(sessionManager).list er(imageId);78 public List<Comment> list(Integer imageId) throws IOException { 79 return CommentDao.getInstance(sessionManager).list(imageId); 80 80 } 81 81 … … 88 88 * @throws IOException 89 89 */ 90 public boolean cre er(String content, Integer imageId, String auteur) throws IOException {91 Comment comment aire= new Comment();92 comment aire.setContent(content);93 comment aire.setImageId(imageId);94 comment aire.setAuthor(auteur);95 return CommentDao.getInstance(sessionManager).cre er(commentaire);90 public boolean create(String content, Integer imageId, String auteur) throws IOException { 91 Comment comment = new Comment(); 92 comment.setContent(content); 93 comment.setImageId(imageId); 94 comment.setAuthor(auteur); 95 return CommentDao.getInstance(sessionManager).create(comment); 96 96 } 97 97 -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/ImageService.java
r9387 r9392 9 9 import fr.mael.jiwigo.transverse.session.SessionManager; 10 10 import fr.mael.jiwigo.transverse.util.ImagesUtil; 11 import fr.mael.jiwigo.transverse.util. Outil;11 import fr.mael.jiwigo.transverse.util.Tools; 12 12 13 13 /* … … 78 78 * Lists all images for a category 79 79 * @param categoryId the id of the category 80 * @param rafraichir true : refresh the list of images81 80 * @return the list of images 82 81 * @throws IOException 83 82 */ 84 public List<Image> list erParCategory(Integer categoryId, boolean rafraichir) throws IOException {85 return ImageDao.getInstance(sessionManager).list erParCategory(categoryId, rafraichir);83 public List<Image> listByCategory(Integer categoryId, boolean rafraichir) throws IOException { 84 return ImageDao.getInstance(sessionManager).listByCategory(categoryId, rafraichir); 86 85 } 87 86 … … 92 91 * @param originalWidth width for the original image 93 92 * @param originalHeight height for the original image 94 * @return 93 * @return true if the image is created 95 94 * @throws Exception 96 95 */ 97 public boolean cre er(String filePath, Integer idCategory, Integer originalWidth, Integer originalHeight,96 public boolean create(String filePath, Integer idCategory, Integer originalWidth, Integer originalHeight, 98 97 Double chunckSize, Integer privacyLevel) throws Exception { 99 98 File originalFile = new File(filePath); 100 99 //get the byte array of the original file, to keep metadata 101 byte[] bytesFichierOriginal = Outil.getBytesFromFile(originalFile);100 byte[] bytesFichierOriginal = Tools.getBytesFromFile(originalFile); 102 101 103 102 //resize the picture (or not) … … 114 113 //the methode Outil.enrich will fail, but the procedure has to continue 115 114 try { 116 byte[] fichierEnrichi = Outil.enrich(bytesFichierOriginal, Outil.getBytesFromFile(new File(System115 byte[] fichierEnrichi = Tools.enrich(bytesFichierOriginal, Tools.getBytesFromFile(new File(System 117 116 .getProperty("java.io.tmpdir") 118 117 + "/originale.jpg"))); 119 Outil.byteToFile(System.getProperty("java.io.tmpdir") + "/originale.jpg", fichierEnrichi);118 Tools.byteToFile(System.getProperty("java.io.tmpdir") + "/originale.jpg", fichierEnrichi); 120 119 } catch (Exception e) { 121 120 } … … 131 130 image.setPrivacyLevel(String.valueOf(privacyLevel)); 132 131 //now we call the dao to send the image to the webservice 133 return ImageDao.getInstance(sessionManager).cre er(image, chunckSize);132 return ImageDao.getInstance(sessionManager).create(image, chunckSize); 134 133 } 135 134 … … 142 141 */ 143 142 public boolean addTags(Image image, String tagId) throws IOException { 144 return ImageDao.getInstance(sessionManager).addTags(image.getIdentifi ant(), tagId);143 return ImageDao.getInstance(sessionManager).addTags(image.getIdentifier(), tagId); 145 144 } 146 145 -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/TagService.java
r9387 r9392 77 77 * @throws IOException 78 78 */ 79 public List<Tag> list er() throws IOException {80 return TagDao.getInstance(sessionManager).list er();79 public List<Tag> list() throws IOException { 80 return TagDao.getInstance(sessionManager).list(); 81 81 } 82 82 … … 87 87 * @throws IOException 88 88 */ 89 public boolean cre er(String nom) throws IOException {89 public boolean create(String nom) throws IOException { 90 90 Tag tag = new Tag(); 91 tag.setN om(nom);92 return TagDao.getInstance(sessionManager).cre er(tag);91 tag.setName(nom); 92 return TagDao.getInstance(sessionManager).create(tag); 93 93 } 94 94 -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/SessionManager.java
r9387 r9392 18 18 19 19 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 20 import fr.mael.jiwigo.transverse.util. Outil;20 import fr.mael.jiwigo.transverse.util.Tools; 21 21 22 22 /* … … 65 65 * the entered password 66 66 */ 67 private String motDePasse;67 private String password; 68 68 /** 69 69 * the url of the site … … 103 103 * true : an error was found for the proxy 104 104 */ 105 private boolean erreurProxy;105 private boolean proxyError; 106 106 107 107 /** 108 108 * Constructor 109 109 * @param login the login 110 * @param motDePassethe password110 * @param password the password 111 111 * @param url the url of the site 112 112 */ 113 public SessionManager(String login, String motDePasse, String url) {113 public SessionManager(String login, String password, String url) { 114 114 this.login = login; 115 this. motDePasse = motDePasse;115 this.password = password; 116 116 this.url = url + "/ws.php"; 117 117 MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); … … 140 140 } 141 141 try { 142 doc = execute rReturnDocument(MethodsEnum.LOGIN.getLabel(), "username", login, "password", motDePasse);143 return Outil.checkOk(doc);142 doc = executeReturnDocument(MethodsEnum.LOGIN.getLabel(), "username", login, "password", password); 143 return Tools.checkOk(doc); 144 144 } catch (Exception e) { 145 LOG.error( Outil.getStackTrace(e));145 LOG.error(Tools.getStackTrace(e)); 146 146 } 147 147 return false; … … 155 155 * @throws UnsupportedEncodingException 156 156 */ 157 public String execute rReturnString(String methode, String... parametres) throws UnsupportedEncodingException {157 public String executeReturnString(String methode, String... parametres) throws UnsupportedEncodingException { 158 158 if (parametres.length % 2 != 0 && !(parametres == null)) { 159 159 try { 160 160 throw new Exception("Le nombre de parametres doit etre pair"); 161 161 } catch (Exception e) { 162 LOG.error( Outil.getStackTrace(e));162 LOG.error(Tools.getStackTrace(e)); 163 163 return null; 164 164 } … … 180 180 // System.out.println(Outil.readInputStreamAsString(streamResponse)); 181 181 // String toReturn = method.getResponseBodyAsString(); 182 String toReturn = Outil.readInputStreamAsString(streamResponse);182 String toReturn = Tools.readInputStreamAsString(streamResponse); 183 183 LOG.debug(toReturn); 184 184 return toReturn; 185 185 } catch (HttpException e) { 186 186 // TODO Auto-generated catch block 187 LOG.error( Outil.getStackTrace(e));187 LOG.error(Tools.getStackTrace(e)); 188 188 } catch (IOException e) { 189 189 // TODO Auto-generated catch block 190 LOG.error( Outil.getStackTrace(e));190 LOG.error(Tools.getStackTrace(e)); 191 191 } catch (IllegalArgumentException e) { 192 LOG.error( Outil.getStackTrace(e));192 LOG.error(Tools.getStackTrace(e)); 193 193 } finally { 194 194 method.releaseConnection(); … … 205 205 * @throws IOException 206 206 */ 207 public Document execute rReturnDocument(String methode, String... parametres) throws IOException {207 public Document executeReturnDocument(String methode, String... parametres) throws IOException { 208 208 try { 209 return Outil.stringToDocument(executerReturnString(methode, parametres));209 return Tools.stringToDocument(executeReturnString(methode, parametres)); 210 210 } catch (JDOMException e) { 211 211 // TODO Auto-generated catch block 212 LOG.error( Outil.getStackTrace(e));212 LOG.error(Tools.getStackTrace(e)); 213 213 } 214 214 return null; … … 221 221 * @return the result 222 222 */ 223 public Document execute rReturnDocument(String methode) {223 public Document executeReturnDocument(String methode) { 224 224 try { 225 return Outil.stringToDocument(executerReturnString(methode));225 return Tools.stringToDocument(executeReturnString(methode)); 226 226 } catch (JDOMException e) { 227 227 // TODO Auto-generated catch block 228 LOG.error( Outil.getStackTrace(e));228 LOG.error(Tools.getStackTrace(e)); 229 229 } catch (IOException e) { 230 230 // TODO Auto-generated catch block 231 LOG.error( Outil.getStackTrace(e));231 LOG.error(Tools.getStackTrace(e)); 232 232 } 233 233 return null; … … 250 250 251 251 /** 252 * @return the motDePasse253 */254 public String getMotDePasse() {255 return motDePasse;256 }257 258 /**259 * @param motDePasse the motDePasse to set260 */261 public void setMotDePasse(String motDePasse) {262 this.motDePasse = motDePasse;263 }264 265 /**266 252 * @return the url 267 253 */ … … 312 298 } 313 299 314 /** 315 * @return the erreurProxy 316 */ 317 public boolean isErreurProxy() { 318 return erreurProxy; 300 public String getPassword() { 301 return password; 302 } 303 304 public void setPassword(String password) { 305 this.password = password; 306 } 307 308 public boolean isProxyError() { 309 return proxyError; 310 } 311 312 public void setProxyError(boolean proxyError) { 313 this.proxyError = proxyError; 319 314 } 320 315 -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/ImagesUtil.java
r9387 r9392 87 87 88 88 /** 89 * @return 89 * @return the graphics configuration 90 90 */ 91 91 public static GraphicsConfiguration getDefaultConfiguration() { -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/Tools.java
r9387 r9392 63 63 * 64 64 */ 65 public class Outil{65 public class Tools { 66 66 /** 67 67 * Logger 68 68 */ 69 public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog( Outil.class);69 public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(Tools.class); 70 70 71 71 /** … … 129 129 */ 130 130 public static URL getURL(String fileName) { 131 URLClassLoader urlLoader = (URLClassLoader) Outil.class.getClassLoader();131 URLClassLoader urlLoader = (URLClassLoader) Tools.class.getClassLoader(); 132 132 URL fileLocation = urlLoader.findResource(fileName); 133 133 return fileLocation; … … 205 205 } else { 206 206 LOG.error("Resultat : " + doc.getRootElement().getAttributeValue("stat") + "\nDocument retourné : \n" 207 + Outil.documentToString(doc));207 + Tools.documentToString(doc)); 208 208 return false; 209 209 }
Note: See TracChangeset
for help on using the changeset viewer.