Changeset 6840


Ignore:
Timestamp:
Sep 2, 2010, 7:34:07 PM (10 years ago)
Author:
mlg
Message:

Two minor improvements :

  • I now get the responses of piwigo's webservices as stream, and not as string any more.
  • The information panel now displays which file is being processed.
Location:
extensions/jiwigo/trunk/src/main
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/service/ImageService.java

    r6833 r6840  
    7777     */
    7878    public boolean creer(String filePath, Integer idCategory) throws Exception {
    79         MainFrame.getInstance().setReussiteMessage(Messages.getMessage("mainFrame_resizing"));
     79        MainFrame.getInstance().setReussiteMessage(Messages.getMessage("mainFrame_resizing") + " " + filePath);
    8080        //get the byte array of the original file, to keep metadata
    8181        byte[] bytesFichierOriginal = Outil.getBytesFromFile(new File(filePath));
     
    9898            //I use here a try catch because if the original file isn't a jpeg
    9999            //the methode Outil.enrich will fail, but the procedure has to continue
    100             MainFrame.getInstance().setReussiteMessage(Messages.getMessage("mainFrame_addMetadata"));
     100            MainFrame.getInstance().setReussiteMessage(Messages.getMessage("mainFrame_addMetadata") + " " + filePath);
    101101            try {
    102102                byte[] fichierEnrichi = Outil.enrich(bytesFichierOriginal, Outil.getBytesFromFile(new File(System
     
    115115        image.setOriginale(originale);
    116116        image.setIdCategory(idCategory);
    117         MainFrame.getInstance().setReussiteMessage(Messages.getMessage("mainFrame_sendingFiles"));
     117        MainFrame.getInstance().setReussiteMessage(Messages.getMessage("mainFrame_sendingFiles") + " " + filePath);
    118118        //now we call the dao to send the image to the webservice
    119119        return ImageDao.getInstance().creer(image);
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/session/SessionManager.java

    r6832 r6840  
    22
    33import java.io.IOException;
     4import java.io.InputStream;
    45
    56import javax.swing.JOptionPane;
     
    125126        try {
    126127            client.executeMethod(method);
    127             String toReturn = method.getResponseBodyAsString();
     128            InputStream streamResponse = method.getResponseBodyAsStream();
     129            //      System.out.println(Outil.readInputStreamAsString(streamResponse));
     130            //      String toReturn = method.getResponseBodyAsString();
     131            String toReturn = Outil.readInputStreamAsString(streamResponse);
    128132            LOG.debug(toReturn);
    129133            return toReturn;
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/util/Outil.java

    r6831 r6840  
    11package fr.mael.jiwigo.transverse.util;
    22
    3 import java.io.BufferedInputStream;
     3import java.io.BufferedReader;
    44import java.io.ByteArrayInputStream;
    55import java.io.ByteArrayOutputStream;
    6 import java.io.DataInputStream;
    76import java.io.File;
    87import java.io.FileInputStream;
     
    109import java.io.IOException;
    1110import java.io.InputStream;
     11import java.io.InputStreamReader;
    1212import java.io.PrintWriter;
    1313import java.io.StringReader;
     
    7676     */
    7777    public static String readInputStreamAsString(InputStream input) throws IOException {
    78         DataInputStream dis = new DataInputStream(new BufferedInputStream(input));
    79 
    80         String temp;
    81         StringBuffer buffer = new StringBuffer();
    82         while ((temp = dis.readLine()) != null) {
    83             buffer.append(temp);
    84         }
    85         return buffer.toString();
     78        //      DataInputStream dis = new DataInputStream(new BufferedInputStream(input));
     79        //
     80        //      String temp;
     81        //      StringBuffer buffer = new StringBuffer();
     82        //      while ((temp = dis.readLine()) != null) {
     83        //          buffer.append(temp);
     84        //      }
     85        //      return buffer.toString();
     86        StringWriter writer = new StringWriter();
     87        InputStreamReader streamReader = new InputStreamReader(input);
     88        //le buffer permet le readline
     89        BufferedReader buffer = new BufferedReader(streamReader);
     90        String line = "";
     91        while (null != (line = buffer.readLine())) {
     92            writer.write(line);
     93        }
     94        // Sortie finale dans le String
     95        return writer.toString();
    8696    }
    8797
  • extensions/jiwigo/trunk/src/main/resources/fr/mael/jiwigo/trad/messages.properties

    r6833 r6840  
    1717mainFrame_editionMenu=Edition
    1818mainFrame_preferencesMenu=Preferences
    19 mainFrame_resizing=Resizing...
    20 mainFrame_addMetadata=Adding metadata...
    21 mainFrame_sendingFiles=Sending files...
     19mainFrame_resizing=Resizing for
     20mainFrame_addMetadata=Adding metadata for
     21mainFrame_sendingFiles=Sending files for
    2222
    2323#####################################################
  • extensions/jiwigo/trunk/src/main/resources/fr/mael/jiwigo/trad/messages_fr.properties

    r6833 r6840  
    1717mainFrame_editionMenu=Edition
    1818mainFrame_preferencesMenu=Préférences
    19 mainFrame_resizing=Redimensionnements...
    20 mainFrame_addMetadata=Ajout des métadonnées...
    21 mainFrame_sendingFiles=Envoi des fichiers...
     19mainFrame_resizing=Redimensionnements pour
     20mainFrame_addMetadata=Ajout des métadonnées pour
     21mainFrame_sendingFiles=Envoi des fichiers pour
    2222
    2323#####################################################
  • extensions/jiwigo/trunk/src/main/resources/log4j.xml

    r6821 r6840  
    2323        <!-- Déclaration loggers -->
    2424        <logger name="fr.mael.jiwigo" additivity="false">
    25                 <level value="DEBUG" />
     25                <level value="INFO" />
    2626                <appender-ref ref="console" />
    2727                <appender-ref ref="fichier" />
Note: See TracChangeset for help on using the changeset viewer.