- Timestamp:
- Mar 27, 2011, 1:03:05 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.