Index: /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CategoryDao.java
===================================================================
--- /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CategoryDao.java	(revision 9892)
+++ /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CategoryDao.java	(revision 9893)
@@ -11,4 +11,5 @@
 import fr.mael.jiwigo.transverse.enumeration.CategoryEnum;
 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum;
+import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
 import fr.mael.jiwigo.transverse.session.SessionManager;
@@ -112,4 +113,6 @@
 	} catch (IOException e) {
 	    LOG.error(Tools.getStackTrace(e));
+	} catch (FileAlreadyExistsException e) {
+	    LOG.error(Tools.getStackTrace(e));
 	}
 	return false;
Index: /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CommentDao.java
===================================================================
--- /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CommentDao.java	(revision 9892)
+++ /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/CommentDao.java	(revision 9893)
@@ -10,4 +10,5 @@
 import fr.mael.jiwigo.om.Comment;
 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum;
+import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
 import fr.mael.jiwigo.transverse.session.SessionManager;
@@ -113,7 +114,12 @@
 	    e.printStackTrace();
 	}
-	return Tools.checkOk(sessionManager.executeReturnDocument(MethodsEnum.AJOUTER_COMMENTAIRE.getLabel(),
-		"image_id", String.valueOf(commentaire.getImageId()), "author", commentaire.getAuthor(), "content",
-		commentaire.getContent(), "key", key));
+	try {
+	    return Tools.checkOk(sessionManager.executeReturnDocument(MethodsEnum.AJOUTER_COMMENTAIRE.getLabel(),
+		    "image_id", String.valueOf(commentaire.getImageId()), "author", commentaire.getAuthor(), "content",
+		    commentaire.getContent(), "key", key));
+	} catch (FileAlreadyExistsException e) {
+	    LOG.error(Tools.getStackTrace(e));
+	    return false;
+	}
 
     }
Index: /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/ImageDao.java
===================================================================
--- /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/ImageDao.java	(revision 9892)
+++ /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/ImageDao.java	(revision 9893)
@@ -3,4 +3,5 @@
 import java.io.File;
 import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -13,4 +14,5 @@
 import fr.mael.jiwigo.om.Image;
 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum;
+import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
 import fr.mael.jiwigo.transverse.exception.WrongChunkSizeException;
@@ -133,8 +135,12 @@
      * @param image the image to create
      * @return true if the creation of the image was the successful
+     * @throws IOException
+     * @throws NoSuchAlgorithmException
+     * @throws WrongChunkSizeException
      * @throws Exception
      */
     //TODO ne pas continuer si une des reponses precedentes est negative
-    public boolean create(Image image, Double chunkSize) throws Exception {
+    public boolean create(Image image, Double chunkSize) throws FileAlreadyExistsException, IOException,
+	    ProxyAuthenticationException, NoSuchAlgorithmException, WrongChunkSizeException {
 	//thumbnail converted to base64
 	BASE64Encoder base64 = new BASE64Encoder();
@@ -201,5 +207,10 @@
 	Document doc = sessionManager.executeReturnDocument(MethodsEnum.SET_INFO.getLabel(), "image_id", String
 		.valueOf(imageId), "tag_ids", tagId);
-	return Tools.checkOk(doc);
+	try {
+	    return Tools.checkOk(doc);
+	} catch (FileAlreadyExistsException e) {
+	    LOG.error(Tools.getStackTrace(e));
+	    return false;
+	}
 
     }
Index: /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/TagDao.java
===================================================================
--- /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/TagDao.java	(revision 9892)
+++ /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/TagDao.java	(revision 9893)
@@ -12,4 +12,5 @@
 import fr.mael.jiwigo.transverse.enumeration.MethodsEnum;
 import fr.mael.jiwigo.transverse.enumeration.TagEnum;
+import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
 import fr.mael.jiwigo.transverse.session.SessionManager;
@@ -105,4 +106,6 @@
 	} catch (IOException e) {
 	    LOG.error(Tools.getStackTrace(e));
+	} catch (FileAlreadyExistsException e) {
+	    e.printStackTrace();
 	}
 	return false;
Index: /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/ImageService.java
===================================================================
--- /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/ImageService.java	(revision 9892)
+++ /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/ImageService.java	(revision 9893)
@@ -3,9 +3,12 @@
 import java.io.File;
 import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
 import java.util.List;
 
 import fr.mael.jiwigo.dao.ImageDao;
 import fr.mael.jiwigo.om.Image;
+import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException;
 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
+import fr.mael.jiwigo.transverse.exception.WrongChunkSizeException;
 import fr.mael.jiwigo.transverse.session.SessionManager;
 import fr.mael.jiwigo.transverse.util.ImagesUtil;
@@ -80,8 +83,14 @@
      * @param originalHeight height for the original image
      * @return true if the image is created
+     * @throws IOException
+     * @throws WrongChunkSizeException
+     * @throws ProxyAuthenticationException
+     * @throws FileAlreadyExistsException
+     * @throws NoSuchAlgorithmException
      * @throws Exception
      */
     public boolean create(String filePath, Integer idCategory, Integer originalWidth, Integer originalHeight,
-	    Double chunckSize, Integer privacyLevel) throws Exception {
+	    Double chunckSize, Integer privacyLevel) throws IOException, NoSuchAlgorithmException,
+	    FileAlreadyExistsException, ProxyAuthenticationException, WrongChunkSizeException {
 	File originalFile = new File(filePath);
 	//get the byte array of the original file, to keep metadata
Index: /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/exception/FileAlreadyExistsException.java
===================================================================
--- /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/exception/FileAlreadyExistsException.java	(revision 9893)
+++ /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/exception/FileAlreadyExistsException.java	(revision 9893)
@@ -0,0 +1,19 @@
+package fr.mael.jiwigo.transverse.exception;
+
+/*
+ *  jiwigo-ws-api Piwigo webservice access Api
+ *  Copyright (c) 2010-2011 Mael mael@le-guevel.com
+ *                All Rights Reserved
+ *
+ *  This library is free software. It comes without any warranty, to
+ *  the extent permitted by applicable law. You can redistribute it
+ *  and/or modify it under the terms of the Do What The Fuck You Want
+ *  To Public License, Version 2, as published by Sam Hocevar. See
+ *  http://sam.zoy.org/wtfpl/COPYING for more details.
+ */
+public class FileAlreadyExistsException extends Exception {
+    public FileAlreadyExistsException(String msg) {
+	super(msg);
+    }
+
+}
Index: /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/ImagesUtil.java
===================================================================
--- /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/ImagesUtil.java	(revision 9892)
+++ /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/ImagesUtil.java	(revision 9893)
@@ -97,7 +97,8 @@
      * @param height the height
      * @return true if successful
+     * @throws IOException
      * @throws Exception
      */
-    public static boolean scale(String filePath, String tempName, int width, int height) throws Exception {
+    public static boolean scale(String filePath, String tempName, int width, int height) throws IOException {
 	File file = new File(filePath);
 	InputStream imageStream = new BufferedInputStream(new FileInputStream(filePath));
Index: /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/Tools.java
===================================================================
--- /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/Tools.java	(revision 9892)
+++ /extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/Tools.java	(revision 9893)
@@ -17,4 +17,5 @@
 import java.net.URLClassLoader;
 import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 
@@ -32,4 +33,6 @@
 import org.jdom.output.XMLOutputter;
 
+import fr.mael.jiwigo.transverse.exception.FileAlreadyExistsException;
+
 /*
  *  jiwigo-ws-api Piwigo webservice access Api
@@ -123,7 +126,9 @@
      * @param filename the path of the file
      * @return the checksum
+     * @throws IOException
+     * @throws NoSuchAlgorithmException
      * @throws Exception
      */
-    public static String getMD5Checksum(String filename) throws Exception {
+    public static String getMD5Checksum(String filename) throws NoSuchAlgorithmException, IOException {
 	byte[] b = createChecksum(filename);
 	String result = "";
@@ -138,7 +143,9 @@
      * @param filename the path of the file
      * @return the checksum as array byte
+     * @throws NoSuchAlgorithmException
+     * @throws IOException
      * @throws Exception
      */
-    private static byte[] createChecksum(String filename) throws Exception {
+    private static byte[] createChecksum(String filename) throws NoSuchAlgorithmException, IOException {
 	InputStream fis = new FileInputStream(filename);
 
@@ -185,5 +192,5 @@
      * @return true if ok
      */
-    public static boolean checkOk(Document doc) {
+    public static boolean checkOk(Document doc) throws FileAlreadyExistsException {
 	if (doc.getRootElement().getAttributeValue("stat").equals("ok")) {
 	    return true;
@@ -191,4 +198,7 @@
 	    LOG.error("Resultat : " + doc.getRootElement().getAttributeValue("stat") + "\nDocument retourné : \n"
 		    + Tools.documentToString(doc));
+	    if (doc.getRootElement().getChild("err").getAttributeValue("msg").equals("file already exists")) {
+		throw new FileAlreadyExistsException("The file already exists on the server");
+	    }
 	    return false;
 	}
