Index: extensions/jiwigo-ws-api/pom.xml
===================================================================
--- extensions/jiwigo-ws-api/pom.xml	(revision 10091)
+++ extensions/jiwigo-ws-api/pom.xml	(revision 10494)
@@ -3,5 +3,5 @@
   <groupId>fr.mael.jiwigo</groupId>
   <artifactId>jiwigo-ws-api</artifactId>
-  <version>0.2b</version>
+  <version>0.3.0-SNAPSHOT</version>
   <dependencies>
 
@@ -36,5 +36,11 @@
 		<scope>test</scope>
 	</dependency>
-
+	<dependency>
+		<groupId>org.apache.httpcomponents</groupId>
+		<artifactId>httpmime</artifactId>
+		<version>4.1.1</version>
+		<type>jar</type>
+		<scope>compile</scope>
+	</dependency>
   </dependencies>
 
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 10091)
+++ extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/ImageDao.java	(revision 10494)
@@ -1,4 +1,5 @@
 package fr.mael.jiwigo.dao;
 
+import java.io.File;
 import java.io.IOException;
 import java.security.NoSuchAlgorithmException;
@@ -68,3 +69,14 @@
     public List<Image> search(String searchString) throws IOException, ProxyAuthenticationException;
 
+    /**
+     * Uses the pwg.images.addsimple web API to add a new picture
+     * http://piwigo.org/doc/doku.php?id=en:dev:webapi:pwg.images.addsimple
+     * 
+     * @param file
+     * @param category
+     * @param title
+     * @throws IOException
+     */
+    public void addSimple(File file, Integer category, String title) throws IOException;
+
 }
Index: extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/ImageDaoImpl.java
===================================================================
--- extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/ImageDaoImpl.java	(revision 10091)
+++ extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/ImageDaoImpl.java	(revision 10494)
@@ -1,6 +1,9 @@
 package fr.mael.jiwigo.dao.impl;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
@@ -8,4 +11,11 @@
 import java.util.List;
 
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.BufferedHttpEntity;
+import org.apache.http.entity.mime.MultipartEntity;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.content.StringBody;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -23,4 +33,5 @@
 import fr.mael.jiwigo.transverse.exception.WrongChunkSizeException;
 import fr.mael.jiwigo.transverse.session.SessionManager;
+import fr.mael.jiwigo.transverse.session.impl.SessionManagerImpl;
 import fr.mael.jiwigo.transverse.util.Tools;
 
@@ -89,6 +100,6 @@
 	    Document doc = null;
 	    if (categoryId != null) {
-		doc = sessionManager.executeReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel(), "cat_id", String
-			.valueOf(categoryId));
+		doc = sessionManager.executeReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel(), "cat_id",
+			String.valueOf(categoryId));
 	    } else {
 		doc = sessionManager.executeReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel());
@@ -133,6 +144,6 @@
 	//sends the thumbnail and gets the result
 	Document reponseThumb = (sessionManager.executeReturnDocument("pwg.images.addChunk", "data", thumbnailBase64,
-		"type", "thumb", "position", "1", "original_sum", Tools.getMD5Checksum(image.getOriginale()
-			.getAbsolutePath())));
+		"type", "thumb", "position", "1", "original_sum",
+		Tools.getMD5Checksum(image.getOriginale().getAbsolutePath())));
 
 	//begin feature:0001827
@@ -147,6 +158,6 @@
 	    String originaleBase64 = base64.encode(Tools.getBytesFromFile(fichierAEnvoyer));
 	    Document reponseOriginale = (sessionManager.executeReturnDocument("pwg.images.addChunk", "data",
-		    originaleBase64, "type", "file", "position", String.valueOf(i), "original_sum", Tools
-			    .getMD5Checksum(image.getOriginale().getAbsolutePath())));
+		    originaleBase64, "type", "file", "position", String.valueOf(i), "original_sum",
+		    Tools.getMD5Checksum(image.getOriginale().getAbsolutePath())));
 	    if (!Tools.checkOk(reponseOriginale)) {
 		echec = true;
@@ -157,9 +168,10 @@
 
 	//add the image in the database and get the result of the webservice
-	Document reponseAjout = (sessionManager.executeReturnDocument("pwg.images.add", "file_sum", Tools
-		.getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum", Tools.getMD5Checksum(image
-		.getThumbnail().getCanonicalPath()), "position", "1", "original_sum", Tools.getMD5Checksum(image
-		.getOriginale().getAbsolutePath()), "categories", String.valueOf(image.getIdCategory()), "name", image
-		.getName(), "author", sessionManager.getLogin(), "level", image.getPrivacyLevel()));
+	Document reponseAjout = (sessionManager.executeReturnDocument("pwg.images.add", "file_sum",
+		Tools.getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum",
+		Tools.getMD5Checksum(image.getThumbnail().getCanonicalPath()), "position", "1", "original_sum",
+		Tools.getMD5Checksum(image.getOriginale().getAbsolutePath()), "categories",
+		String.valueOf(image.getIdCategory()), "name", image.getName(), "author", sessionManager.getLogin(),
+		"level", image.getPrivacyLevel()));
 	LOG.debug("Response add : " + Tools.documentToString(reponseAjout));
 	//	System.out.println(Main.sessionManager.executerReturnString("pwg.images.add", "file_sum", Outil
@@ -189,6 +201,6 @@
      */
     public boolean addTags(Integer imageId, String tagId) throws IOException, ProxyAuthenticationException {
-	Document doc = sessionManager.executeReturnDocument(MethodsEnum.SET_INFO.getLabel(), "image_id", String
-		.valueOf(imageId), "tag_ids", tagId);
+	Document doc = sessionManager.executeReturnDocument(MethodsEnum.SET_INFO.getLabel(), "image_id",
+		String.valueOf(imageId), "tag_ids", tagId);
 	try {
 	    return Tools.checkOk(doc);
@@ -260,4 +272,69 @@
     }
 
+    public void addSimple(File file, Integer category, String title) throws IOException {
+	HttpPost httpMethod = new HttpPost(((SessionManagerImpl) sessionManager).getUrl());
+
+	//	nameValuePairs.add(new BasicNameValuePair("method", "pwg.images.addSimple"));
+	//	for (int i = 0; i < parametres.length; i += 2) {
+	//	    nameValuePairs.add(new BasicNameValuePair(parametres[i], parametres[i + 1]));
+	//	}
+	//	method.setEntity(new UrlEncodedFormEntity(nameValuePairs));
+
+	if (file != null) {
+	    MultipartEntity multipartEntity = new MultipartEntity();
+
+	    //		String string = nameValuePairs.toString();
+	    // dirty fix to remove the enclosing entity{}
+	    //		String substring = string.substring(string.indexOf("{"),
+	    //				string.lastIndexOf("}") + 1);
+	    multipartEntity.addPart("method", new StringBody("pwg.images.addSimple"));
+	    multipartEntity.addPart("category", new StringBody(category.toString()));
+	    multipartEntity.addPart("name", new StringBody(title));
+
+	    //		StringBody contentBody = new StringBody(substring,
+	    //				Charset.forName("UTF-8"));
+	    //		multipartEntity.addPart("entity", contentBody);
+	    FileBody fileBody = new FileBody(file);
+	    multipartEntity.addPart("image", fileBody);
+	    ((HttpPost) httpMethod).setEntity(multipartEntity);
+	}
+
+	//	httpMethod.setHeader(X_GALLERY_REQUEST_METHOD, requestMethod);
+	HttpResponse response = ((SessionManagerImpl) sessionManager).getClient().execute(httpMethod);
+	int responseStatusCode = response.getStatusLine().getStatusCode();
+
+	switch (responseStatusCode) {
+	case HttpURLConnection.HTTP_CREATED:
+	    break;
+	case HttpURLConnection.HTTP_OK:
+	    break;
+	case HttpURLConnection.HTTP_BAD_REQUEST:
+	    throw new IOException("status code was : " + responseStatusCode);
+	case HttpURLConnection.HTTP_FORBIDDEN:
+	    throw new IOException("status code was : " + responseStatusCode);
+	case HttpURLConnection.HTTP_NOT_FOUND:
+	    throw new IOException("status code was : " + responseStatusCode);
+	default:
+	    throw new IOException("status code was : " + responseStatusCode);
+	}
+
+	HttpEntity resultEntity = response.getEntity();
+	BufferedHttpEntity responseEntity = new BufferedHttpEntity(resultEntity);
+
+	BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
+	String line;
+	StringBuilder sb = new StringBuilder();
+	try {
+	    while ((line = reader.readLine()) != null) {
+		sb.append(line);
+		sb.append("\n");
+	    }
+	} finally {
+	    reader.close();
+	}
+	String stringResult = sb.toString();
+
+    }
+
     public SessionManager getSessionManager() {
 	return sessionManager;
@@ -267,4 +344,3 @@
 	this.sessionManager = sessionManager;
     }
-
 }
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 10091)
+++ extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/ImageService.java	(revision 10494)
@@ -1,4 +1,5 @@
 package fr.mael.jiwigo.service;
 
+import java.io.File;
 import java.io.IOException;
 import java.security.NoSuchAlgorithmException;
@@ -59,3 +60,14 @@
     public List<Image> search(String queryString) throws IOException, ProxyAuthenticationException;
 
+    /**
+     * Uses the pwg.images.addsimple web API to add a new picture
+     * http://piwigo.org/doc/doku.php?id=en:dev:webapi:pwg.images.addsimple
+     * 
+     * @param file
+     * @param category
+     * @param title
+     * @throws IOException
+     */
+    public void addSimple(File file, Integer category, String title) throws IOException;
+
 }
Index: extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/impl/ImageServiceImpl.java
===================================================================
--- extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/impl/ImageServiceImpl.java	(revision 10091)
+++ extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/impl/ImageServiceImpl.java	(revision 10494)
@@ -90,7 +90,6 @@
 	    //the methode Outil.enrich will fail, but the procedure has to continue
 	    try {
-		byte[] fichierEnrichi = Tools.enrich(bytesFichierOriginal, Tools.getBytesFromFile(new File(System
-			.getProperty("java.io.tmpdir")
-			+ "/originale.jpg")));
+		byte[] fichierEnrichi = Tools.enrich(bytesFichierOriginal,
+			Tools.getBytesFromFile(new File(System.getProperty("java.io.tmpdir") + "/originale.jpg")));
 		Tools.byteToFile(System.getProperty("java.io.tmpdir") + "/originale.jpg", fichierEnrichi);
 	    } catch (Exception e) {
@@ -145,4 +144,9 @@
     }
 
+    public void addSimple(File file, Integer category, String title) throws IOException {
+	dao.addSimple(file, category, title);
+
+    }
+
     public ImageDao getDao() {
 	return dao;
Index: extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/impl/SessionManagerImpl.java
===================================================================
--- extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/impl/SessionManagerImpl.java	(revision 10091)
+++ extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/impl/SessionManagerImpl.java	(revision 10494)
@@ -327,3 +327,7 @@
     }
 
+    public DefaultHttpClient getClient() {
+	return client;
+    }
+
 }
Index: extensions/jiwigo-ws-api/src/test/java/fr/mael/jiwigo/service/ServicesTest.java
===================================================================
--- extensions/jiwigo-ws-api/src/test/java/fr/mael/jiwigo/service/ServicesTest.java	(revision 10091)
+++ extensions/jiwigo-ws-api/src/test/java/fr/mael/jiwigo/service/ServicesTest.java	(revision 10494)
@@ -1,3 +1,7 @@
 package fr.mael.jiwigo.service;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
 
 import junit.framework.Assert;
@@ -17,35 +21,75 @@
 public class ServicesTest {
 
-	private SessionManager sessionManager;
+    private SessionManager sessionManager;
 
-	@Before
-	public void setUp() {
-		sessionManager = new SessionManagerImpl("mael", "motdepasse", "http://mael.piwigo.com", "Unit Test");
-		sessionManager.processLogin();
+    @Before
+    public void setUp() {
+	sessionManager = new SessionManagerImpl("mael", "motdepasse", "http://mael.piwigo.com", "Unit Test");
+	sessionManager.processLogin();
+    }
+
+    @Test
+    public void testCreer() throws Exception {
+	Category cat = null;
+	CategoryServiceImpl categoryService = new CategoryServiceImpl();
+	CategoryDaoImpl categoryDao = new CategoryDaoImpl();
+	categoryDao.setSessionManager(sessionManager);
+	categoryService.setDao(categoryDao);
+
+	ImageServiceImpl imageService = new ImageServiceImpl();
+	ImageDaoImpl imageDao = new ImageDaoImpl();
+	imageDao.setSessionManager(sessionManager);
+	imageService.setDao(imageDao);
+	//we choose category number 3
+	for (Category category : categoryService.list(true)) {
+	    if (category.getIdentifier().equals(3)) {
+		cat = category;
+		break;
+	    }
+	}
+	//we look for the first picture of category 3
+	Image image = imageService.listByCategory(cat.getIdentifier(), true).get(0);
+	Assert.assertEquals("test de test do not delete", cat.getName());
+	Assert.assertEquals("20110329194915-0c0b3f36.jpg", image.getFile());
+
+    }
+
+    @Test
+    public void addSimpleTest() {
+
+	// we prepare the service implementing add-simple
+	ImageServiceImpl imageService = new ImageServiceImpl();
+	ImageDaoImpl dao = new ImageDaoImpl();
+	dao.setSessionManager(sessionManager);
+	imageService.setDao(dao);
+
+	//we prepare the resource to send
+	File imageFile = new File(this.getClass().getClassLoader().getResource("piwigo_org.png").getPath());
+	//	File imageFile = new File("piwigo_org.png");
+	Integer categoryTest = 98;
+	String title = "title" + System.currentTimeMillis();
+	try {
+	    imageService.addSimple(imageFile, categoryTest, title);
+	} catch (IOException e) {
+	    Assert.fail("An exception was thrown while trying to send the pictures" + e.getMessage());
 	}
 
-	@Test
-	public void testCreer() throws Exception {
-		Category cat = null;
-		CategoryServiceImpl categoryService = new CategoryServiceImpl();
-		CategoryDaoImpl categoryDao = new CategoryDaoImpl();
-		categoryDao.setSessionManager(sessionManager);
-		categoryService.setDao(categoryDao);
+	//the image should be sent, let's check if piwigo added it to the category.
+	boolean found = false;
+	List<Image> listByCategory;
+	try {
+	    listByCategory = imageService.listByCategory(categoryTest, true);
+	    for (Image image : listByCategory) {
+		if (image.getName().equals(title)) {
+		    found = true;
+		    break;
+		}
+	    }
+	} catch (Exception e) {
+	    Assert.fail("An exception was thrown while trying to fetch the pictures from category " + categoryTest
+		    + "exception was : " + e.getMessage());
+	}
+	Assert.assertTrue("The picture just sent could not be found", found);
 
-		ImageServiceImpl imageService = new ImageServiceImpl();
-		ImageDaoImpl imageDao = new ImageDaoImpl();
-		imageDao.setSessionManager(sessionManager);
-		imageService.setDao(imageDao);
-
-		for (Category category : categoryService.list(true)) {
-			if (category.getIdentifier().equals(3)) {
-				cat = category;
-				break;
-			}
-		}
-		Image image = imageService.listByCategory(cat.getIdentifier(), true).get(0);
-		Assert.assertEquals("test de test do not delete", cat.getName());
-		Assert.assertEquals("20110329194915-0c0b3f36.jpg", image.getFile());
-
-	}
+    }
 }
