r135 - in trunk: . src/main/java/org/nuiton/scmwebeditor/actions
Author: kcardineaud Date: 2011-06-24 10:13:58 +0200 (Fri, 24 Jun 2011) New Revision: 135 Url: http://nuiton.org/repositories/revision/scmwebeditor/135 Log: ScmWebEditor use the method String generate(String xslListOrOutType, String in) for parsing rst Modified: trunk/pom.xml trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-06-24 08:07:02 UTC (rev 134) +++ trunk/pom.xml 2011-06-24 08:13:58 UTC (rev 135) @@ -50,7 +50,7 @@ <dependency> <groupId>org.nuiton.jrst</groupId> <artifactId>jrst</artifactId> - <version>${jrstPluginVersion}</version> + <version>1.4-SNAPSHOT</version> <scope>compile</scope> <exclusions> <exclusion> @@ -199,7 +199,7 @@ <dependency> <groupId>org.nuiton.jrst</groupId> <artifactId>doxia-module-jrst</artifactId> - <version>${jrstPluginVersion}</version> + <version>1.4-SNAPSHOT</version> </dependency> </dependencies> </plugin> Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java =================================================================== --- trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java 2011-06-24 08:07:02 UTC (rev 134) +++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java 2011-06-24 08:13:58 UTC (rev 135) @@ -1,14 +1,8 @@ package org.nuiton.scmwebeditor.actions; -import java.io.File; -import java.io.IOException; - - import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.interceptor.ServletRequestAware; @@ -62,31 +56,11 @@ log.debug("Enter in preview action"); } - HttpSession httpSession = request.getSession(true); - File tmpDir = getTempDir(httpSession); - //Text recuperation - String myData = newText; - //Text formating and tempfile creating - String myDataWithoutcrlf = myData.replace("\r", ""); - File fileInDirCopy = new File(tmpDir, "copy" + httpSession.getId() + ".rst"); - File httpFile = new File(tmpDir, "preview" + httpSession.getId() + ".html"); - try { - fileInDirCopy.createNewFile(); - httpFile.createNewFile(); - FileUtils.writeStringToFile(fileInDirCopy, myDataWithoutcrlf); - } catch (IOException e) { - if(log.isErrorEnabled()) { - log.error("read/write error",e); - } - } - - convertToUnicode(fileInDirCopy); - File copy = new File(tmpDir, "copy" + httpSession.getId() + ".rst"); //Using jrst for generate html document try { - JRST.generate(JRST.TYPE_HTML, copy, httpFile, JRST.Overwrite.ALLTIME); + XMLResponse = JRST.generate(JRST.TYPE_HTML, newText); if(log.isDebugEnabled()) { log.debug("RST generate"); } @@ -97,19 +71,10 @@ XMLResponse = "<h4>Parsing error, please read RST specification<h4>"; return; } - copy.delete(); + - - try { - XMLResponse = FileUtils.readFileToString(httpFile); - } catch (IOException e) { - e.printStackTrace(); - } - httpFile.delete(); - - } static public PreviewAction getAction() {
participants (1)
-
kcardineaud@users.nuiton.org