Changeset 9893
- Timestamp:
- Mar 27, 2011, 1:03:05 PM (13 years ago)
- Location:
- extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CategoryDao.java
r9879 r9893 11 11 import fr.mael.jiwigo.transverse.enumeration.CategoryEnum; 12 12 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 13 import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException; 13 14 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException; 14 15 import fr.mael.jiwigo.transverse.session.SessionManager; … … 112 113 } catch (IOException e) { 113 114 LOG.error(Tools.getStackTrace(e)); 115 } catch (FileAlreadyExistsException e) { 116 LOG.error(Tools.getStackTrace(e)); 114 117 } 115 118 return false; -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CommentDao.java
r9879 r9893 10 10 import fr.mael.jiwigo.om.Comment; 11 11 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 12 import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException; 12 13 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException; 13 14 import fr.mael.jiwigo.transverse.session.SessionManager; … … 113 114 e.printStackTrace(); 114 115 } 115 return Tools.checkOk(sessionManager.executeReturnDocument(MethodsEnum.AJOUTER_COMMENTAIRE.getLabel(), 116 "image_id", String.valueOf(commentaire.getImageId()), "author", commentaire.getAuthor(), "content", 117 commentaire.getContent(), "key", key)); 116 try { 117 return Tools.checkOk(sessionManager.executeReturnDocument(MethodsEnum.AJOUTER_COMMENTAIRE.getLabel(), 118 "image_id", String.valueOf(commentaire.getImageId()), "author", commentaire.getAuthor(), "content", 119 commentaire.getContent(), "key", key)); 120 } catch (FileAlreadyExistsException e) { 121 LOG.error(Tools.getStackTrace(e)); 122 return false; 123 } 118 124 119 125 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/ImageDao.java
r9879 r9893 3 3 import java.io.File; 4 4 import java.io.IOException; 5 import java.security.NoSuchAlgorithmException; 5 6 import java.util.ArrayList; 6 7 import java.util.HashMap; … … 13 14 import fr.mael.jiwigo.om.Image; 14 15 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 16 import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException; 15 17 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException; 16 18 import fr.mael.jiwigo.transverse.exception.WrongChunkSizeException; … … 133 135 * @param image the image to create 134 136 * @return true if the creation of the image was the successful 137 * @throws IOException 138 * @throws NoSuchAlgorithmException 139 * @throws WrongChunkSizeException 135 140 * @throws Exception 136 141 */ 137 142 //TODO ne pas continuer si une des reponses precedentes est negative 138 public boolean create(Image image, Double chunkSize) throws Exception { 143 public boolean create(Image image, Double chunkSize) throws FileAlreadyExistsException, IOException, 144 ProxyAuthenticationException, NoSuchAlgorithmException, WrongChunkSizeException { 139 145 //thumbnail converted to base64 140 146 BASE64Encoder base64 = new BASE64Encoder(); … … 201 207 Document doc = sessionManager.executeReturnDocument(MethodsEnum.SET_INFO.getLabel(), "image_id", String 202 208 .valueOf(imageId), "tag_ids", tagId); 203 return Tools.checkOk(doc); 209 try { 210 return Tools.checkOk(doc); 211 } catch (FileAlreadyExistsException e) { 212 LOG.error(Tools.getStackTrace(e)); 213 return false; 214 } 204 215 205 216 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/TagDao.java
r9879 r9893 12 12 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 13 13 import fr.mael.jiwigo.transverse.enumeration.TagEnum; 14 import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException; 14 15 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException; 15 16 import fr.mael.jiwigo.transverse.session.SessionManager; … … 105 106 } catch (IOException e) { 106 107 LOG.error(Tools.getStackTrace(e)); 108 } catch (FileAlreadyExistsException e) { 109 e.printStackTrace(); 107 110 } 108 111 return false; -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/ImageService.java
r9879 r9893 3 3 import java.io.File; 4 4 import java.io.IOException; 5 import java.security.NoSuchAlgorithmException; 5 6 import java.util.List; 6 7 7 8 import fr.mael.jiwigo.dao.ImageDao; 8 9 import fr.mael.jiwigo.om.Image; 10 import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException; 9 11 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException; 12 import fr.mael.jiwigo.transverse.exception.WrongChunkSizeException; 10 13 import fr.mael.jiwigo.transverse.session.SessionManager; 11 14 import fr.mael.jiwigo.transverse.util.ImagesUtil; … … 80 83 * @param originalHeight height for the original image 81 84 * @return true if the image is created 85 * @throws IOException 86 * @throws WrongChunkSizeException 87 * @throws ProxyAuthenticationException 88 * @throws FileAlreadyExistsException 89 * @throws NoSuchAlgorithmException 82 90 * @throws Exception 83 91 */ 84 92 public boolean create(String filePath, Integer idCategory, Integer originalWidth, Integer originalHeight, 85 Double chunckSize, Integer privacyLevel) throws Exception { 93 Double chunckSize, Integer privacyLevel) throws IOException, NoSuchAlgorithmException, 94 FileAlreadyExistsException, ProxyAuthenticationException, WrongChunkSizeException { 86 95 File originalFile = new File(filePath); 87 96 //get the byte array of the original file, to keep metadata -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/ImagesUtil.java
r9879 r9893 97 97 * @param height the height 98 98 * @return true if successful 99 * @throws IOException 99 100 * @throws Exception 100 101 */ 101 public static boolean scale(String filePath, String tempName, int width, int height) throws Exception {102 public static boolean scale(String filePath, String tempName, int width, int height) throws IOException { 102 103 File file = new File(filePath); 103 104 InputStream imageStream = new BufferedInputStream(new FileInputStream(filePath)); -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/Tools.java
r9879 r9893 17 17 import java.net.URLClassLoader; 18 18 import java.security.MessageDigest; 19 import java.security.NoSuchAlgorithmException; 19 20 import java.util.ArrayList; 20 21 … … 32 33 import org.jdom.output.XMLOutputter; 33 34 35 import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException; 36 34 37 /* 35 38 * jiwigo-ws-api Piwigo webservice access Api … … 123 126 * @param filename the path of the file 124 127 * @return the checksum 128 * @throws IOException 129 * @throws NoSuchAlgorithmException 125 130 * @throws Exception 126 131 */ 127 public static String getMD5Checksum(String filename) throws Exception {132 public static String getMD5Checksum(String filename) throws NoSuchAlgorithmException, IOException { 128 133 byte[] b = createChecksum(filename); 129 134 String result = ""; … … 138 143 * @param filename the path of the file 139 144 * @return the checksum as array byte 145 * @throws NoSuchAlgorithmException 146 * @throws IOException 140 147 * @throws Exception 141 148 */ 142 private static byte[] createChecksum(String filename) throws Exception {149 private static byte[] createChecksum(String filename) throws NoSuchAlgorithmException, IOException { 143 150 InputStream fis = new FileInputStream(filename); 144 151 … … 185 192 * @return true if ok 186 193 */ 187 public static boolean checkOk(Document doc) {194 public static boolean checkOk(Document doc) throws FileAlreadyExistsException { 188 195 if (doc.getRootElement().getAttributeValue("stat").equals("ok")) { 189 196 return true; … … 191 198 LOG.error("Resultat : " + doc.getRootElement().getAttributeValue("stat") + "\nDocument retourné : \n" 192 199 + Tools.documentToString(doc)); 200 if (doc.getRootElement().getChild("err").getAttributeValue("msg").equals("file already exists")) { 201 throw new FileAlreadyExistsException("The file already exists on the server"); 202 } 193 203 return false; 194 204 }
Note: See TracChangeset
for help on using the changeset viewer.