Index: topia/src/java/org/codelutin/topia/TopiaContext.java diff -u topia/src/java/org/codelutin/topia/TopiaContext.java:1.57 topia/src/java/org/codelutin/topia/TopiaContext.java:1.58 --- topia/src/java/org/codelutin/topia/TopiaContext.java:1.57 Thu Dec 8 16:48:46 2005 +++ topia/src/java/org/codelutin/topia/TopiaContext.java Thu Dec 8 17:44:42 2005 @@ -23,15 +23,20 @@ * * @author Benjamin Poussin * Copyright Code Lutin -* @version $Revision: 1.57 $ +* @version $Revision: 1.58 $ * -* Mise a jour: $Date: 2005/12/08 16:48:46 $ +* Mise a jour: $Date: 2005/12/08 17:44:42 $ * par : $Author: thimel $ */ package org.codelutin.topia; +import java.io.BufferedReader; import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; @@ -711,10 +716,24 @@ * @param handler le gestionnaire d'erreurs associé */ public void copyFromContext(TopiaContext otherContext, ErrorHandler handler) throws TopiaException { - StringWriter from = new StringWriter(); - otherContext.exportToXMLAll(from); - StringReader incomming = new StringReader(from.getBuffer().toString()); - importFromXML(incomming, handler); + File tmp = null; + try { + tmp = File.createTempFile("topiaContextCopy", null); + BufferedWriter from = new BufferedWriter(new FileWriter(tmp)); + otherContext.exportToXMLAll(from); + from.close(); + BufferedReader incomming = new BufferedReader(new FileReader(tmp)); + importFromXML(incomming, handler); + incomming.close(); + } catch (IOException ioe) { + throw new TopiaException("Creation/Ecriture d'un fichier temporaire impossible. Copie interrompue", ioe); + } finally { + if (tmp != null) { + if (!tmp.delete() && log.isInfoEnabled()) { + log.info("Suppression du fichier \"" + tmp.getAbsolutePath() + "\" a echoue"); + } + } + } } } // TopiaContext