Changeset 9394


Ignore:
Timestamp:
02/27/11 15:44:30 (9 years ago)
Author:
mlg
Message:

Major bug fix :
The ImageService allowed the chunk size to be 0 which led to fill the temporary folder.
Now an exception is thrown if the value is 0

Location:
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/ImageDao.java

    r9392 r9394  
    99import org.jdom.Document; 
    1010import org.jdom.Element; 
    11 import org.jdom.output.XMLOutputter; 
    1211 
    1312import sun.misc.BASE64Encoder; 
    1413import fr.mael.jiwigo.om.Image; 
    1514import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 
     15import fr.mael.jiwigo.transverse.exception.WrongChunkSizeException; 
    1616import fr.mael.jiwigo.transverse.session.SessionManager; 
    1717import fr.mael.jiwigo.transverse.util.Tools; 
     
    7474    private SessionManager sessionManager; 
    7575 
     76    private ArrayList<File> filesToSend; 
     77 
    7678    /** 
    7779     * Private singleton, to use a singleton 
     
    157159        //begin feature:0001827 
    158160        int chunk = chunkSize.intValue(); 
    159         ArrayList<File> fichiersAEnvoyer = Tools.splitFile(image.getOriginale(), chunk); 
     161        if (chunk == 0) { 
     162            throw new WrongChunkSizeException("Error : the chunk size cannot be 0"); 
     163        } 
     164        filesToSend = Tools.splitFile(image.getOriginale(), chunk); 
    160165        boolean echec = false; 
    161         for (int i = 0; i < fichiersAEnvoyer.size(); i++) { 
    162             File fichierAEnvoyer = fichiersAEnvoyer.get(i); 
     166        for (int i = 0; i < filesToSend.size(); i++) { 
     167            File fichierAEnvoyer = filesToSend.get(i); 
    163168            String originaleBase64 = base64.encode(Tools.getBytesFromFile(fichierAEnvoyer)); 
    164169            Document reponseOriginale = (sessionManager.executeReturnDocument("pwg.images.addChunk", "data", 
     
    228233            myImage.setIdentifier(Integer.valueOf(im.getAttributeValue("id"))); 
    229234            myImage.setName(im.getChildText("name")); 
    230             System.out.println(new XMLOutputter().outputString(im)); 
    231235            //      myImage.setIdCategory(Integer.valueOf(im.getChild("categories").getChild("category") 
    232236            //              .getAttributeValue("id"))); 
     
    258262        file = new File(System.getProperty("java.io.tmpdir") + "/thumb.jpg"); 
    259263        file.delete(); 
     264        for (File tempCut : filesToSend) { 
     265            tempCut.delete(); 
     266        } 
    260267 
    261268    } 
  • extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/ImageService.java

    r9392 r9394  
    130130        image.setPrivacyLevel(String.valueOf(privacyLevel)); 
    131131        //now we call the dao to send the image to the webservice 
    132         return ImageDao.getInstance(sessionManager).create(image, chunckSize); 
     132        return ImageDao.getInstance(sessionManager).create(image, chunckSize * 1000000); 
    133133    } 
    134134 
  • extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/SessionManager.java

    r9392 r9394  
    167167        method.addParameter("method", methode); 
    168168        for (int i = 0; i < parametres.length; i += 2) { 
    169             System.out.println(parametres[i] + " -> " + parametres[i + 1]); 
     169            //      System.out.println(parametres[i] + " -> " + parametres[i + 1]); 
    170170            method.addParameter(parametres[i], parametres[i + 1]); 
    171171 
Note: See TracChangeset for help on using the changeset viewer.