Sandbox-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
October 2009
- 6 participants
- 38 discussions
r272 - / nuiton-rstedit nuiton-rstedit/src nuiton-rstedit/src/main nuiton-rstedit/src/main/java nuiton-rstedit/src/main/java/org nuiton-rstedit/src/main/java/org/nuiton nuiton-rstedit/src/main/java/org/nuiton/jrst nuiton-rstedit/src/main/resources nuiton-rstedit/src/main/webapp nuiton-rstedit/src/main/webapp/WEB-INF nuiton-rstedit/src/test
by glorieux@users.nuiton.org 06 Oct '09
by glorieux@users.nuiton.org 06 Oct '09
06 Oct '09
Author: glorieux
Date: 2009-10-06 16:58:40 +0200 (Tue, 06 Oct 2009)
New Revision: 272
Added:
nuiton-rstedit/
nuiton-rstedit/LICENSE.txt
nuiton-rstedit/README.txt
nuiton-rstedit/changelog.txt
nuiton-rstedit/pom.xml
nuiton-rstedit/src/
nuiton-rstedit/src/main/
nuiton-rstedit/src/main/java/
nuiton-rstedit/src/main/java/org/
nuiton-rstedit/src/main/java/org/nuiton/
nuiton-rstedit/src/main/java/org/nuiton/jrst/
nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java
nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java
nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java
nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java
nuiton-rstedit/src/main/resources/
nuiton-rstedit/src/main/resources/log4j.properties
nuiton-rstedit/src/main/webapp/
nuiton-rstedit/src/main/webapp/BadFileRedirect.jsp
nuiton-rstedit/src/main/webapp/Error.jsp
nuiton-rstedit/src/main/webapp/GereFormSize.js
nuiton-rstedit/src/main/webapp/GereSession.js
nuiton-rstedit/src/main/webapp/ModificationViewer.jsp
nuiton-rstedit/src/main/webapp/OutConnection.jsp
nuiton-rstedit/src/main/webapp/Preview.js
nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp
nuiton-rstedit/src/main/webapp/Recall.jsp
nuiton-rstedit/src/main/webapp/Redirect.jsp
nuiton-rstedit/src/main/webapp/Saver.js
nuiton-rstedit/src/main/webapp/WEB-INF/
nuiton-rstedit/src/main/webapp/WEB-INF/web.xml
nuiton-rstedit/src/main/webapp/cancelRedirect.js
nuiton-rstedit/src/main/webapp/cancelRedirectDelete.js
nuiton-rstedit/src/test/
nuiton-rstedit/src/test/java/
Log:
Added: nuiton-rstedit/LICENSE.txt
===================================================================
--- nuiton-rstedit/LICENSE.txt (rev 0)
+++ nuiton-rstedit/LICENSE.txt 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: nuiton-rstedit/README.txt
===================================================================
--- nuiton-rstedit/README.txt (rev 0)
+++ nuiton-rstedit/README.txt 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Added: nuiton-rstedit/pom.xml
===================================================================
--- nuiton-rstedit/pom.xml (rev 0)
+++ nuiton-rstedit/pom.xml 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,173 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom</artifactId>
+ <version>1.0.2</version>
+ </parent>
+
+ <artifactId>nuiton-rstedit</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.tmatesoft.svnkit</groupId>
+ <artifactId>svnkit</artifactId>
+ <version>1.2.3.5521</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.jrst</groupId>
+ <artifactId>jrst</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.cpdetector</groupId>
+ <artifactId>cpdetector</artifactId>
+ <version>1.0.7</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>codelutin-repository</id>
+ <name>CodeLutinRepository</name>
+ <url>http://lutinbuilder.labs.libre-entreprise.org/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ </repository>
+ </repositories>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton-rstedit</name>
+ <description>.
+ </description>
+ <inceptionYear>2009</inceptionYear>
+ <url>http://maven-site.nuiton.org/${project.artifactId}</url>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>war</packaging>
+
+ <properties>
+
+
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.jrst</groupId>
+ <artifactId>doxia-module-jrst</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ </build>
+
+ <!-- Source control management. -->
+ <scm>
+ <connection>scm:svn:http://svn.nuiton.org/svn/mavenpom/nuiton-rstedit/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/mavenpom/nuiton-rstedit/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/mavenpom/nuiton-rstedit/trunk</url>
+ </scm>
+
+ <profiles>
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+
+ <plugins>
+
+ <!-- launch in a release the assembly automaticly -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-assemblies</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>false</attach>
+ <descriptorRefs>
+ <descriptorRef>deps</descriptorRef>
+ <descriptorRef>full</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,340 @@
+package org.nuiton.jrst;
+
+import info.monitorenter.cpdetector.io.ASCIIDetector;
+import info.monitorenter.cpdetector.io.ByteOrderMarkDetector;
+import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
+import info.monitorenter.cpdetector.io.JChardetFacade;
+import info.monitorenter.cpdetector.io.ParsingDetector;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.tmatesoft.svn.core.SVNAuthenticationException;
+import org.tmatesoft.svn.core.SVNDepth;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNProperty;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNCommitClient;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.wc.SVNUpdateClient;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+
+/**
+ * @author geoffroy lorieux
+ */
+public class HelloServlet extends HttpServlet {
+
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ * Do checkout on a private or not scm and call modification jsp page
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ try {
+
+// First Part Svn checkout and JSP call
+ log.debug("--------------------------");
+ log.debug("Connection to SCMWebEditor");
+ log.debug("--------------------------");
+ System.setProperty("file.encoding", "UTF-8");
+
+ if (request.getParameter("adresse") != null && request.getParameter("file_name") != null && request.getParameter("project_url") != null){
+ if (request.getParameter("adresse").equals("") == true || request.getParameter("file_name").equals("") == true || request.getParameter("project_url").equals("") == true){
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/BadFileRedirect.jsp");
+ requestDispacher.forward(request, response);
+ return;
+ }
+
+ } else {
+ SvnSession svnSess = (SvnSession)request.getSession(true).getAttribute("myInfo");
+ if (svnSess != null){
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+ }
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/OutConnection.jsp");
+ requestDispacher.forward(request, response);
+ return;
+ }
+ HttpSession httpSession = request.getSession(true);
+ log.debug("Le nom du fichier est : "+request.getParameter("file_name"));
+// svnSession object creation if doesn't already exist
+
+ SvnSession svnSess = (SvnSession) httpSession.getAttribute("myInfo");
+
+ if (svnSess == null){
+ svnSess = new SvnSession((request.getParameter("adresse").startsWith("scm:svn:") == true ? request.getParameter("adresse").replace("scm:svn:", "") : request.getParameter("adresse")),
+ request.getParameter("file_name"), request.getParameter("project_url"),
+ null, null, (File) getServletContext().getAttribute("javax.servlet.context.tempdir"),httpSession.getId());
+ } else if (svnSess.getLogin() != null && svnSess.getPassword() != null){
+ String tmp_log = svnSess.getLogin();
+ String tmp_pass = svnSess.getPassword();
+ svnSess = new SvnSession((request.getParameter("adresse").startsWith("scm:svn:") == true ? request.getParameter("adresse").replace("scm:svn:", "") : request.getParameter("adresse")),
+ request.getParameter("file_name"), request.getParameter("project_url"),
+ tmp_log, tmp_pass, (File) getServletContext().getAttribute("javax.servlet.context.tempdir"),httpSession.getId());
+ }
+
+ PrintWriter out = response.getWriter();
+
+// UTF-8 Test
+ if (SVNProperty.isUTF8(svnSess.getSvnOption().getNativeCharset()) == true){
+ log.debug("Je suis en utf8");
+ } else {
+ log.debug("Je ne suis pas en utf8");
+ }
+
+ httpSession.setAttribute("myInfo", svnSess);
+// Tempdir creation
+
+ log.debug("Creating temporary directory on: " + svnSess.getCheckoutdir());
+
+ svnSess.getCheckoutdir().mkdir();
+// doCheckout declaration
+
+ DAVRepositoryFactory.setup();
+ SVNUpdateClient upclient = new SVNUpdateClient(svnSess.getManager(), svnSess.getSvnOption());
+
+// Checkout svn and file organisation
+ try{
+ log.debug("Do Checkout");
+ upclient.doCheckout(svnSess.getRemoteUrl(), svnSess.getCheckoutdir(),
+ SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.FILES, false);
+ } catch (SVNAuthenticationException authexep) {
+// if svn authentication failed user is redirected on login page
+ log.debug("Private SCM on reading");
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+ request.setAttribute("adresse", svnSess.getSvnPath());
+ request.setAttribute("file_name", svnSess.getFileName());
+ request.setAttribute("projectUrl", svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/PrivateSvnRedirect.jsp");
+ requestDispacher.forward(request, response);
+ return;
+ }
+ log.debug("Checkout done");
+
+ File file_in_dir = new File(svnSess.getCheckoutdir(), svnSess.getFileName());
+ try {
+ String original_text = FileUtils.readFileToString(file_in_dir);
+ request.setAttribute("OrigText", original_text);
+ request.setAttribute("InvalidateMaxTime", (httpSession.getMaxInactiveInterval()/60));
+ log.debug("Invalidate time is :"+(httpSession.getMaxInactiveInterval()/60));
+ request.setAttribute("IsLogin", (svnSess.getLogin() != null && svnSess.getPassword() != null ? true : false));
+ log.debug("IsLogin : "+(svnSess.getLogin() != null && svnSess.getPassword() != null ? true : false));
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/ModificationViewer.jsp");
+ // End on first part
+ requestDispacher.forward(request, response);
+ out.close();
+ } catch (FileNotFoundException ee){
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/BadFileRedirect.jsp");
+ requestDispacher.forward(request, response);
+ return;
+ }
+// JSP data transfert
+
+ } catch (SVNException ex) {
+ SvnSession svnSess = (SvnSession)request.getSession(true).getAttribute("myInfo");
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/BadFileRedirect.jsp");
+ requestDispacher.forward(request, response);
+ return;
+
+ }
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ * Receve the new text and commit it to scm
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException{
+ try {
+
+// Second Part Client response and SVN commit
+ System.setProperty("file.encoding", "UTF-8");
+ HttpSession httpSession = request.getSession(true);
+ SvnSession svnSess = (SvnSession) httpSession.getAttribute("myInfo");
+
+// Resetting authentification information and manager
+ svnSess.setLogin(svnSess.getLogin() != null ? svnSess.getLogin() : request.getParameter("username"));
+ svnSess.setPassword(svnSess.getPassword() != null ? svnSess.getPassword() : request.getParameter("pw"));
+ svnSess.setAuthManager(SVNWCUtil.createDefaultAuthenticationManager(svnSess.getCheckoutdir(), svnSess.getLogin(), svnSess.getPassword(), false));
+ svnSess.setManager(SVNClientManager.newInstance(svnSess.getSvnOption(), svnSess.getAuthManager()));
+
+ File pathToFile = new File(svnSess.getCheckoutdir(), svnSess.getFileName());
+
+ SVNCommitClient commitClient = new SVNCommitClient(svnSess.getManager(), svnSess.getSvnOption());
+ FileUtils.writeStringToFile(pathToFile, request.getParameter("Mytext"));
+
+ List<File> list = new java.util.ArrayList<File>(1);
+ list.add(0, pathToFile);
+
+ list = convertToUnicode(list);
+
+ File[] tabFile = new File[1];
+ tabFile[0] = pathToFile;
+// Sending Data to SVN
+
+ if (request.getParameter("Mytext").equals(request.getParameter("Orig_text")) == false){
+ try{
+ log.debug("Do Commit");
+ commitClient.doCommit(tabFile, false, request.getParameter("Commit_message"), null, null, false, true, SVNDepth.FILES);
+ } catch (SVNAuthenticationException authexep) {
+ // if authentication failed edition page is reload form user's relogin
+ log.debug("Bad Login or Password");
+ response.setStatus(401);
+ request.setAttribute("svnPath_url", svnSess.getSvnPath());
+ request.setAttribute("fileName_url", svnSess.getFileName());
+ request.setAttribute("Redirection_url", svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/Error.jsp");
+ requestDispacher.forward(request, response);
+ return;
+ }
+ }
+// if commit success user is redirect on the project page
+ log.debug("Redirect");
+ request.setAttribute("Redirection_url", svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/Redirect.jsp");
+// Deleting temp directory
+
+ log.debug("Deleting temporary directory : " + svnSess.getCheckoutdir());
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+// End of Second part
+
+ requestDispacher.forward(request, response);
+ log.debug("Exit RSTEditor");
+
+ } catch (SVNException ex) {
+ Logger.getLogger(HelloServlet.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ protected static CodepageDetectorProxy detector;
+ private static final Log log = LogFactory.getLog(HelloServlet.class);
+
+ protected static CodepageDetectorProxy getCodepageDetector() {
+
+ if (detector == null) {
+ detector = CodepageDetectorProxy.getInstance(); // A singleton.
+
+ // Add the implementations of info.monitorenter.cpdetector.io.ICodepageDetector:
+ // This one is quick if we deal with unicode codepages:
+ detector.add(new ByteOrderMarkDetector());
+ // The first instance delegated to tries to detect the meta charset attribut in html pages.
+ detector.add(new ParsingDetector(true)); // be verbose about parsing.
+ // This one does the tricks of exclusion and frequency detection, if first implementation is
+ // unsuccessful:
+ detector.add(JChardetFacade.getInstance()); // Another singleton.
+ detector.add(ASCIIDetector.getInstance()); // Fallback, see javadoc.
+ }
+ return detector;
+ }
+
+
+ /**
+ * Convert all files to UTF-8.
+ *
+ * @param files fiels to convert
+ * @return converted file list
+ */
+ public static List<File> convertToUnicode(List<File> files) {
+
+ CodepageDetectorProxy myDetector = getCodepageDetector();
+
+ for (File file : files) {
+ try {
+ Charset charset = myDetector.detectCodepage(file.toURI().toURL());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Charset for " + file.getAbsolutePath() + " is " + charset);
+ }
+
+ if (charset != null && !charset.name().equalsIgnoreCase("UTF-8")) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Convert " + file.getAbsolutePath() + " to unicode");
+ }
+
+ File tmpFile = File.createTempFile(file.getName(), ".copy");
+ tmpFile.deleteOnExit();
+
+ // direct copy
+ InputStream is = new FileInputStream(file);
+ OutputStream os = new FileOutputStream(tmpFile);
+ try {
+ IOUtils.copy(is, os);
+ }
+ finally {
+ is.close();
+ os.close();
+ }
+
+ // copy using cp transaltion
+ is = new FileInputStream(tmpFile);
+ os = new FileOutputStream(file);
+ Reader ir = new InputStreamReader(is, charset);
+ Writer ow = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ try {
+ IOUtils.copy(ir, ow);
+ }
+ finally {
+ ir.close();
+ ow.close();
+ is.close();
+ os.close();
+ }
+
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("File " + file.getAbsolutePath() + " already in unicode : skip");
+ }
+ }
+ } catch (MalformedURLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ }
+
+ }
+
+ return files;
+ }
+}
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,180 @@
+package org.nuiton.jrst;
+
+import info.monitorenter.cpdetector.io.ASCIIDetector;
+import info.monitorenter.cpdetector.io.ByteOrderMarkDetector;
+import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
+import info.monitorenter.cpdetector.io.JChardetFacade;
+import info.monitorenter.cpdetector.io.ParsingDetector;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.List;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author geoffroy lorieux
+ */
+public class PreviewServlet extends HttpServlet {
+
+ /**
+ * Processes requests for <code>POST</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ log.debug("je suis dans la previewservlet");
+ HttpSession httpSession = request.getSession(true);
+ File tmp_dir = (File) getServletContext().getAttribute("javax.servlet.context.tempdir");
+ log.debug("Le tmp dir est :" + tmp_dir);
+ log.debug("Le content type est : " + request.getContentType());
+// Text recuperation
+ String myData = request.getParameter("text");
+// Text formating and tempfile creating
+ String myDataWithoutcrlf = myData.replace("\r", "");
+ File file_in_dir_copy = new File(tmp_dir, "copy"+httpSession.getId()+".rst");
+ File http_file = new File(tmp_dir, "preview"+httpSession.getId()+".html");
+ file_in_dir_copy.createNewFile();
+ http_file.createNewFile();
+ FileUtils.writeStringToFile(file_in_dir_copy, myDataWithoutcrlf);
+ List<File> list = new java.util.ArrayList<File>(1);
+ list.add(0, file_in_dir_copy);
+ list = convertToUnicode(list);
+
+ File copy = new File(tmp_dir, "copy"+httpSession.getId()+".rst");
+// Using jrst for generate html document
+ try{
+ JRST.generate(JRST.TYPE_HTML, copy, http_file, JRST.Overwrite.ALLTIME);
+ log.debug("generate okai");
+ } catch (Exception eee) {
+ log.debug("Bad RST file");
+ response.setStatus(406);
+ return;
+ }
+ copy.delete();
+// Sending html content to pop-up preview page
+ response.setContentType("text/html");
+ PrintWriter ret = response.getWriter();
+ ret.print(FileUtils.readFileToString(http_file));
+ http_file.delete();
+ }
+
+ protected static CodepageDetectorProxy detector;
+ private static final Log log = LogFactory.getLog(PreviewServlet.class);
+
+ protected static CodepageDetectorProxy getCodepageDetector() {
+
+ if (detector == null) {
+ detector = CodepageDetectorProxy.getInstance(); // A singleton.
+
+ // Add the implementations of info.monitorenter.cpdetector.io.ICodepageDetector:
+ // This one is quick if we deal with unicode codepages:
+ detector.add(new ByteOrderMarkDetector());
+ // The first instance delegated to tries to detect the meta charset attribut in html pages.
+ detector.add(new ParsingDetector(true)); // be verbose about parsing.
+ // This one does the tricks of exclusion and frequency detection, if first implementation is
+ // unsuccessful:
+ detector.add(JChardetFacade.getInstance()); // Another singleton.
+ detector.add(ASCIIDetector.getInstance()); // Fallback, see javadoc.
+ }
+ return detector;
+ }
+
+
+ /**
+ * Convert all files to UTF-8.
+ *
+ * @param files fiels to convert
+ * @return converted file list
+ */
+ public static List<File> convertToUnicode(List<File> files) {
+
+ CodepageDetectorProxy myDetector = getCodepageDetector();
+
+ for (File file : files) {
+ try {
+ Charset charset = myDetector.detectCodepage(file.toURI().toURL());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Charset for " + file.getAbsolutePath() + " is " + charset);
+ }
+
+ if (charset != null && !charset.name().equalsIgnoreCase("UTF-8")) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Convert " + file.getAbsolutePath() + " to unicode");
+ }
+
+ File tmpFile = File.createTempFile(file.getName(), ".copy");
+ tmpFile.deleteOnExit();
+
+ // direct copy
+ InputStream is = new FileInputStream(file);
+ OutputStream os = new FileOutputStream(tmpFile);
+ try {
+ IOUtils.copy(is, os);
+ }
+ finally {
+ is.close();
+ os.close();
+ }
+
+ // copy using cp transaltion
+ is = new FileInputStream(tmpFile);
+ os = new FileOutputStream(file);
+ Reader ir = new InputStreamReader(is, charset);
+ Writer ow = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ try {
+ IOUtils.copy(ir, ow);
+ }
+ finally {
+ ir.close();
+ ow.close();
+ is.close();
+ os.close();
+ }
+
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("File " + file.getAbsolutePath() + " already in unicode : skip");
+ }
+ }
+ } catch (MalformedURLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ }
+
+ }
+
+ return files;
+ }
+}
+
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,45 @@
+package org.nuiton.jrst;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+/**
+ * @author geoffroy lorieux
+ */
+public class PrivateSvnServlet extends HttpServlet{
+
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ log.debug("New Log setting");
+ HttpSession httpSession = request.getSession(true);
+ System.setProperty("file.encoding", "UTF-8");
+ PrintWriter out = response.getWriter();
+ SvnSession svnSess = (SvnSession) httpSession.getAttribute("myInfo");
+// Resetting User Information
+ svnSess.setLogin(request.getParameter("username"));
+ svnSess.setPassword(request.getParameter("pw"));
+ svnSess.setAuthManager(SVNWCUtil.createDefaultAuthenticationManager(svnSess.getCheckoutdir(),svnSess.getLogin(), svnSess.getPassword(), false));
+ svnSess.setManager(SVNClientManager.newInstance(svnSess.getSvnOption(), svnSess.getAuthManager()));
+ httpSession.setAttribute("myInfo", svnSess);
+// Recalling helloservlet with user information stock on session
+ request.setAttribute("Redirect_url",
+ "http://localhost:8080/nuiton-rstedit/hello?adresse="+svnSess.getSvnPath()+"&"+"file_name="+svnSess.getFileName()+"&"+"project_url="+svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/Recall.jsp");
+
+ requestDispacher.forward(request, response);
+ out.close();
+ }
+ private static final Log log = LogFactory.getLog(PrivateSvnServlet.class);
+}
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,129 @@
+package org.nuiton.jrst;
+
+import java.io.File;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNProperty;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
+import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+class SvnSession {
+
+ public ISVNAuthenticationManager getAuthManager() {
+ return authManager;
+ }
+
+ public void setAuthManager(ISVNAuthenticationManager authManager) {
+ this.authManager = authManager;
+ }
+
+ public File getCheckoutdir() {
+ return checkoutdir;
+ }
+
+ public void setCheckoutdir(File checkoutdir) {
+ this.checkoutdir = checkoutdir;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getLogin() {
+ return login;
+ }
+
+ public void setLogin(String login) {
+ this.login = login;
+ }
+
+ public SVNClientManager getManager() {
+ return manager;
+ }
+
+ public void setManager(SVNClientManager manager) {
+ this.manager = manager;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getProjectUrl() {
+ return projectUrl;
+ }
+
+ public void setProjectUrl(String projectUrl) {
+ this.projectUrl = projectUrl;
+ }
+
+ public SVNURL getRemoteUrl() {
+ return remoteUrl;
+ }
+
+ public void setRemoteUrl(SVNURL remoteUrl) {
+ this.remoteUrl = remoteUrl;
+ }
+
+ public DefaultSVNOptions getSvnOption() {
+ return svnOption;
+ }
+
+ public void setSvnOption(DefaultSVNOptions svnOption) {
+ this.svnOption = svnOption;
+ }
+
+ public String getSvnPath() {
+ return svnPath;
+ }
+
+ public void setSvnPath(String svnPath) {
+ this.svnPath = svnPath;
+ }
+
+ public File getTmpDir() {
+ return tmpDir;
+ }
+
+ public void setTmpDir(File tmpDir) {
+ this.tmpDir = tmpDir;
+ }
+
+ String svnPath;// svn path without fileName
+ String fileName;// fileName of modif file
+ String projectUrl;// Projectname
+ String login;// user's login
+ String password;// user's password
+ File tmpDir;// Temp directory path
+ File checkoutdir;// Temp directory for checkout
+ SVNURL remoteUrl;// url of svn path
+ ISVNAuthenticationManager authManager;// AuthenticationManager with login and password
+ DefaultSVNOptions svnOption;// svn default option
+ SVNClientManager manager;
+
+ SvnSession(String svnPath, String fileName, String projectUrl, String login, String password, File tmpDir, String id) throws SVNException {
+ super();
+ this.svnPath = svnPath;
+ this.fileName = fileName;
+ this.projectUrl = projectUrl;
+ this.login = login;
+ this.password = password;
+ this.tmpDir = tmpDir;
+ this.checkoutdir = new File(this.tmpDir, "temp_rst"+id);
+ this.remoteUrl = SVNURL.parseURIEncoded(svnPath);
+ this.authManager = SVNWCUtil.createDefaultAuthenticationManager(this.checkoutdir, this.login, this.password, false);
+ this.svnOption = SVNWCUtil.createDefaultOptions(this.checkoutdir, false);
+ this.svnOption.setPropertyValue(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_LF);
+ this.manager = SVNClientManager.newInstance(this.svnOption, this.authManager);
+ }
+}
Added: nuiton-rstedit/src/main/resources/log4j.properties
===================================================================
--- nuiton-rstedit/src/main/resources/log4j.properties (rev 0)
+++ nuiton-rstedit/src/main/resources/log4j.properties 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,30 @@
+# Global logging configuration
+log4j.rootLogger=DEBUG, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+# File output...
+#log4j.appender.fileout=org.apache.log4j.FileAppender
+#log4j.appender.fileout.File=jtimer.log
+#log4j.appender.fileout.Append=true
+#log4j.appender.fileout.Threshold=DEBUG
+#log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
+#log4j.appender.fileout.layout.ConversionPattern=%5p (%F:%L) %m%n
+
+# Rolling appender
+#log4j.appender.rolling=org.apache.log4j.RollingFileAppender
+#log4j.appender.rolling.File=jtimer.log
+#log4j.appender.rolling.MaxFileSize=100KB
+#log4j.appender.rolling.Append=true
+#log4j.appender.rolling.MaxBackupIndex=30
+#log4j.appender.rolling.Threshold=INFO
+#log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
+#log4j.appender.rolling.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+# package level
+#log4j.logger.org.chorem.jtimer=DEBUG
+#log4j.logger.org.chorem.jtimer.ws=DEBUG
+#log4j.logger.org.chorem.jtimer.ui.report=DEBUG
Added: nuiton-rstedit/src/main/webapp/BadFileRedirect.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/BadFileRedirect.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/BadFileRedirect.jsp 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,23 @@
+<%--
+ Document : BadFileRedirect
+ Created on : 6 oct. 2009, 15:33:56
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Error...</title>
+ <meta http-equiv="Refresh" content="3; url=http://localhost:8080/nuiton-rstedit/hello">
+ </head>
+ <body>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>Bad SCM path or file name! Please correct it.</p>
+ <p>You should be transferred automatically to the form page. If
+not please <a href="http://localhost:8080/nuiton-rstedit/hello">click this link</a>.</p>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/Error.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Error.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Error.jsp 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,22 @@
+<%--
+ Document : Error
+ Created on : 15 sept. 2009, 12:22:29
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Error</title>
+ <meta http-equiv="Refresh" content="2;
+ url=http://localhost:8080/nuiton-rstedit/hello?adresse=<%=request.getAttribute("Svnpath_url")%>&file_name=<%=request.getAttribute("Filename_url")%>&project_url=<%=request.getAttribute("Redirection_url")%>">
+ </head>
+ <body>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>Bad Login or Password. Please Wait.</p>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/GereFormSize.js
===================================================================
--- nuiton-rstedit/src/main/webapp/GereFormSize.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/GereFormSize.js 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,43 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+
+function countLines(strtocount, cols)
+ {
+ var hard_lines = 1;
+ var last = 0;
+ while ( true )
+ {
+ last = strtocount.indexOf("\n", last+1);
+ hard_lines ++;
+ if ( last == -1 )
+ {
+ break;
+ }
+ }
+ var soft_lines = Math.round(strtocount.length / (cols-1));
+ var hard = eval("hard_lines " + unescape("%3e") + "soft_lines;");
+ if ( hard )
+ {
+ soft_lines = hard_lines;
+ }
+ return soft_lines;
+ }
+function cleanForm()
+ {
+ var the_form = document.forms[0];
+ for ( var x in the_form )
+ {
+ if ( ! the_form[x] )
+ {
+ continue;
+ }
+ if( typeof the_form[x].rows != "number" )
+ {
+ continue;
+ }
+ the_form[x].rows = countLines(the_form[x].value,the_form[x].cols) +1;
+ }
+ setTimeout("cleanForm();", 300);
+ }
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/GereSession.js
===================================================================
--- nuiton-rstedit/src/main/webapp/GereSession.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/GereSession.js 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,41 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+function rappelSession(minutes)
+{
+ var msg='Your session expire on '+minutes+' minute';
+ if(minutes>1)
+ {
+ msg+='s';
+ }
+ msg+='.\nDo you want to reload this page ?';
+
+ if(confirm(msg))
+ {
+ location.reload();
+ }
+}
+
+/**
+ * affiche une alerte sur l'expiration de la session et redirige vers une autre page
+ */
+function expirationSession()
+{
+ alert("Your session has expire. Please relogin");
+ window.history.back(-1);
+}
+
+/**
+ * affiche des avertissements sur le délai d'expiration de la session :
+ * - un premier au bout de (expiration-rappel) minutes (par ex. : 20-3 = 17 minutes)
+ * - un second au bout de (expiration) minutes (par ex. : 20 minutes)
+ */
+function geresession(expiration, rappel)
+{
+ // affichage du rappel
+ var chronoRappel=setTimeout('rappelSession('+rappel+')', (expiration-rappel)*60*1000);
+
+ // une fois le rappel affiché, on avertit uniquement de l'expiration
+ var chronoExpiration=setTimeout('expirationSession()', (expiration)*60*1000);
+}
Added: nuiton-rstedit/src/main/webapp/ModificationViewer.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/ModificationViewer.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/ModificationViewer.jsp 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,45 @@
+<%--
+ Document : ModificationViewer
+ Created on : 10 sept. 2009, 13:43:11
+ Author : glorieux
+--%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>SCMWebEditor</title>
+
+ </head>
+<body onload="cleanForm(); geresession(<%=request.getAttribute("InvalidateMaxTime")%>, 5);">
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <center><h2><p>Welcome on SCMWebEditor</p></h2><h4><p>For any Problem with RestruturedText visit <a href="http://docutils.sourceforge.net/rst.html">RST documentation website</a>.</p></h4></center>
+ <center><form method="post" action="/nuiton-rstedit/hello">
+ <script src="GereFormSize.js"></script>
+ <textarea name="Mytext" id="Mytext" rows="20" cols="150"><%=request.getAttribute("OrigText")%></textarea>
+ <script src="Preview.js"></script>
+ <script src="Saver.js"></script>
+ <script src="GereSession.js"></script>
+ <script src="cancelRedirectDelete.js"></script>
+ <p>Commit Message: <input type="text" name="Commit_message"/></p>
+ <%if (request.getAttribute("IsLogin").equals(false) == true){
+ %><p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12></label>
+ <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12></label> </p><%
+ } else {
+ %><input type="hidden" NAME=username><input type="hidden" NAME=pw><%
+ }%>
+ <input type="hidden" name="Orig_text" value="<%=request.getAttribute("OrigText")%>"/>
+ <input type="button" value="Save and Continue Editing" name="SaveandC" onclick="javascript:saver(this.form.Mytext, this.form.username, this.form.pw, this.form.Commit_message, this.form.Orig_text);"/>
+ <input type="submit" value="Save and Quit" name="Save"/>
+ <input type="button" value="Preview" name="Preview" onclick="javascript:preview(this.form.Mytext);"/>
+ <input type="reset" value="Reset" name="Reset" />
+ <input type="button" value="Exit" name="Cancel" onclick="javascript:cancelRedirectDelete(this.form.Orig_text, this.form.username, this.form.pw, this.form.Commit_message);"/>
+ </form></center>
+
+ <h4><p>Older Text Preview :</p></h4>
+ <pre><%=request.getAttribute("OrigText")%></pre>
+</body>
+</html>
Added: nuiton-rstedit/src/main/webapp/OutConnection.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/OutConnection.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/OutConnection.jsp 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,28 @@
+<%--
+ Document : OutConnection
+ Created on : 6 oct. 2009, 12:07:27
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>SCM Web Editor</title>
+ </head>
+ <body>
+ <script src="cancelRedirect.js"></script>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <center><h2><p>Welcome on SCMWebEditor</p></h2><h4><p>You try to access SCM Web Editor from an unknow page please complete this form for application using.</p></h4></center>
+ <center><form method="get" action="/nuiton-rstedit/hello">
+ <p><label>SCM path: <input TYPE=text NAME=adresse SIZE=50></label></p>
+ <p><label>File name: <input TYPE=text NAME=file_name SIZE=20></label></p>
+ <input type="hidden" name="project_url" value="<%=request.getRequestURI()%>"/>
+ <input type="submit" value="Continue" name="Save"/>
+ <input type="button" value="Exit" name="Cancel" onclick="javascript:cancelRedirect();"/>
+ </form></center>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/Preview.js
===================================================================
--- nuiton-rstedit/src/main/webapp/Preview.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/Preview.js 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,56 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+function createRequestObject()
+{
+ var req;
+ if(window.XMLHttpRequest)
+ {
+ //For Firefox, Safari, Opera
+ req = new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ //For IE 5+
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ else
+ {
+ //Error for an old browser
+ alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
+ }
+ return req;
+}
+
+//Make the XMLHttpRequest Object
+var http= createRequestObject();
+
+function sendRequest(method, url, text)
+{
+
+ http.open(method, url, true);
+ http.onreadystatechange = handleResponse;
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.send("text="+text.value);
+}
+
+function handleResponse()
+{
+ if(http.readyState == 4 && http.status != 406)
+ {
+ var response = http.responseText;
+ var wind = window.open("", "Preview", "scrollbars=yes,resizable=yes,status=yes");
+ wind.document.body.innerHTML = response;
+ }
+ else if (http.readyState == 4 && http.status == 406)
+ {
+ alert("Bad RestructuredText file format please correct it.");
+ }
+}
+
+function preview(my_text)
+{
+ sendRequest("POST", "http://localhost:8080/nuiton-rstedit/previewservlet", my_text);
+}
+
Added: nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,29 @@
+<%--
+ Document : PrivateSvnRedirect
+ Created on : 30 sept. 2009, 14:05:43
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Private Scm</title>
+ </head>
+ <body><form method="post" action="/nuiton-rstedit/privatesvnservlet">
+ <script src="cancelRedirect.js"></script>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>You try to access a Private SCM. Please login</p>
+ <p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12></label>
+ <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12></label></p>
+ <input type="submit" value="Submit" name="Save"/>
+ <input type="button" value="Exit" name="Cancel" onclick="cancelRedirect();"/>
+ <input type="hidden" name="adresse" value="<%=request.getAttribute("adresse")%>"/>
+ <input type="hidden" name="file_name" value="<%=request.getAttribute("file_name")%>"/>
+ <input type="hidden" name="project_url" value="<%=request.getAttribute("project_url")%>"/>
+ </form>
+ </body>
+</html>
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/Recall.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Recall.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Recall.jsp 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,17 @@
+<%--
+ Document : Recall
+ Created on : 30 sept. 2009, 17:05:40
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Redirect...</title>
+ <meta http-equiv="Refresh" content="0; url=<%=request.getAttribute("Redirect_url")%>">
+ </head>
+</html>
Added: nuiton-rstedit/src/main/webapp/Redirect.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Redirect.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Redirect.jsp 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,23 @@
+<%--
+ Document : Redirect
+ Created on : 10 sept. 2009, 13:43:11
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Redirection...</title>
+ <meta http-equiv="Refresh" content="2; url=<%=request.getAttribute("Redirection_url")%>">
+ </head>
+ <body>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>Thank you using RSTEditor</p>
+ <p>You should be transferred automatically to the new page. If
+not please <a href="<%=request.getAttribute("Redirection_url")%>">click this link</a>.</p>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/Saver.js
===================================================================
--- nuiton-rstedit/src/main/webapp/Saver.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/Saver.js 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,56 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+function createRequestObject()
+{
+ var req;
+ if(window.XMLHttpRequest)
+ {
+ //For Firefox, Safari, Opera
+ req = new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ //For IE 5+
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ else
+ {
+ //Error for an old browser
+ alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
+ }
+ return req;
+}
+
+//Make the XMLHttpRequest Object
+var http= createRequestObject();
+
+function sendReq(method, url, text, login, pass, message, orig_text)
+{
+ http.open(method, url, true);
+ http.onreadystatechange = handleResp;
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.send("Mytext="+text.value+"&username="+login.value+"&pw="+pass.value+"&Commit_message="+message.value+"&Orig_text="+orig_text.value);
+}
+
+function handleResp()
+{
+ if(http.readyState == 4 && http.status != 401){
+ alert("Save Ok.");
+// window.location.reload(true);
+ } else if (http.readyState == 4 && http.status == 401){
+ alert("Bad login or password please recheck.");
+ }
+}
+
+function saver(my_text, login, pass, message, orig_text)
+{
+ if (my_text.value != orig_text.value){
+ if (confirm("Do you really want to save?")){
+ sendReq("POST", "http://localhost:8080/nuiton-rstedit/hello", my_text, login, pass, message, orig_text);
+ }
+ } else{
+ alert("File don't need to be save.");
+ }
+}
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/WEB-INF/web.xml
===================================================================
--- nuiton-rstedit/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ nuiton-rstedit/src/main/webapp/WEB-INF/web.xml 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
+ <servlet>
+ <servlet-name>HelloServlet</servlet-name>
+ <servlet-class>org.nuiton.jrst.HelloServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>PreviewServlet</servlet-name>
+ <servlet-class>org.nuiton.jrst.PreviewServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>Saveservlet</servlet-name>
+ <servlet-class>Saveservlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>PrivateSvnServlet</servlet-name>
+ <servlet-class>org.nuiton.jrst.PrivateSvnServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>HelloServlet</servlet-name>
+ <url-pattern>/hello</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>PreviewServlet</servlet-name>
+ <url-pattern>/previewservlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Saveservlet</servlet-name>
+ <url-pattern>/saveservlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>PrivateSvnServlet</servlet-name>
+ <url-pattern>/privatesvnservlet</url-pattern>
+ </servlet-mapping>
+ </web-app>
Added: nuiton-rstedit/src/main/webapp/cancelRedirect.js
===================================================================
--- nuiton-rstedit/src/main/webapp/cancelRedirect.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/cancelRedirect.js 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,11 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+
+function cancelRedirect()
+ {
+ if (confirm("Exit SCMWebEditor ?")){
+ window.history.back(-1);
+ }
+ }
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/cancelRedirectDelete.js
===================================================================
--- nuiton-rstedit/src/main/webapp/cancelRedirectDelete.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/cancelRedirectDelete.js 2009-10-06 14:58:40 UTC (rev 272)
@@ -0,0 +1,44 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+function createRequestObjec()
+{
+ var req;
+ if(window.XMLHttpRequest)
+ {
+ //For Firefox, Safari, Opera
+ req = new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ //For IE 5+
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ else
+ {
+ //Error for an old browser
+ alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
+ }
+ return req;
+}
+
+//Make the XMLHttpRequest Object
+var http= createRequestObjec();
+
+function sendRe(method, url, text, login, pass, message)
+{
+ http.open(method, url, true);
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.send("Mytext="+text.value+"&username="+login.value+"&pw="+pass.value+"&Commit_message="+message.value+"&Orig_text="+text.value);
+}
+
+function cancelRedirectDelete(orig_text, login, pass, message)
+ {
+ if (confirm("Exit SCMWebEditor ?")){
+ sendRe("POST", "http://localhost:8080/nuiton-rstedit/hello", orig_text, login, pass, message);
+ window.history.back(-1);
+ }
+ }
\ No newline at end of file
1
0
Author: glorieux
Date: 2009-10-06 16:57:58 +0200 (Tue, 06 Oct 2009)
New Revision: 271
Removed:
nuiton-rstedit/
Log:
1
0
r270 - / nuiton-rstedit nuiton-rstedit/src nuiton-rstedit/src/main nuiton-rstedit/src/main/java nuiton-rstedit/src/main/java/org nuiton-rstedit/src/main/java/org/nuiton nuiton-rstedit/src/main/java/org/nuiton/jrst nuiton-rstedit/src/main/resources nuiton-rstedit/src/main/webapp nuiton-rstedit/src/main/webapp/WEB-INF nuiton-rstedit/src/test
by glorieux@users.nuiton.org 05 Oct '09
by glorieux@users.nuiton.org 05 Oct '09
05 Oct '09
Author: glorieux
Date: 2009-10-05 17:04:40 +0200 (Mon, 05 Oct 2009)
New Revision: 270
Added:
nuiton-rstedit/
nuiton-rstedit/LICENSE.txt
nuiton-rstedit/README.txt
nuiton-rstedit/changelog.txt
nuiton-rstedit/pom.xml
nuiton-rstedit/src/
nuiton-rstedit/src/main/
nuiton-rstedit/src/main/java/
nuiton-rstedit/src/main/java/org/
nuiton-rstedit/src/main/java/org/nuiton/
nuiton-rstedit/src/main/java/org/nuiton/jrst/
nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java
nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java
nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java
nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java
nuiton-rstedit/src/main/resources/
nuiton-rstedit/src/main/resources/log4j.properties
nuiton-rstedit/src/main/webapp/
nuiton-rstedit/src/main/webapp/Error.jsp
nuiton-rstedit/src/main/webapp/GereFormSize.js
nuiton-rstedit/src/main/webapp/GereSession.js
nuiton-rstedit/src/main/webapp/ModificationViewer.jsp
nuiton-rstedit/src/main/webapp/Preview.js
nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp
nuiton-rstedit/src/main/webapp/Recall.jsp
nuiton-rstedit/src/main/webapp/Redirect.jsp
nuiton-rstedit/src/main/webapp/Saver.js
nuiton-rstedit/src/main/webapp/WEB-INF/
nuiton-rstedit/src/main/webapp/WEB-INF/web.xml
nuiton-rstedit/src/main/webapp/cancelRedirect.js
nuiton-rstedit/src/test/
nuiton-rstedit/src/test/java/
Log:
Added: nuiton-rstedit/LICENSE.txt
===================================================================
--- nuiton-rstedit/LICENSE.txt (rev 0)
+++ nuiton-rstedit/LICENSE.txt 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: nuiton-rstedit/README.txt
===================================================================
--- nuiton-rstedit/README.txt (rev 0)
+++ nuiton-rstedit/README.txt 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Added: nuiton-rstedit/pom.xml
===================================================================
--- nuiton-rstedit/pom.xml (rev 0)
+++ nuiton-rstedit/pom.xml 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,173 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom</artifactId>
+ <version>1.0.2</version>
+ </parent>
+
+ <artifactId>nuiton-rstedit</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.tmatesoft.svnkit</groupId>
+ <artifactId>svnkit</artifactId>
+ <version>1.2.3.5521</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.jrst</groupId>
+ <artifactId>jrst</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.cpdetector</groupId>
+ <artifactId>cpdetector</artifactId>
+ <version>1.0.7</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>codelutin-repository</id>
+ <name>CodeLutinRepository</name>
+ <url>http://lutinbuilder.labs.libre-entreprise.org/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ </repository>
+ </repositories>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton-rstedit</name>
+ <description>.
+ </description>
+ <inceptionYear>2009</inceptionYear>
+ <url>http://maven-site.nuiton.org/${project.artifactId}</url>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>war</packaging>
+
+ <properties>
+
+
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.jrst</groupId>
+ <artifactId>doxia-module-jrst</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ </build>
+
+ <!-- Source control management. -->
+ <scm>
+ <connection>scm:svn:http://svn.nuiton.org/svn/mavenpom/nuiton-rstedit/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/mavenpom/nuiton-rstedit/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/mavenpom/nuiton-rstedit/trunk</url>
+ </scm>
+
+ <profiles>
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+
+ <plugins>
+
+ <!-- launch in a release the assembly automaticly -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-assemblies</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>false</attach>
+ <descriptorRefs>
+ <descriptorRef>deps</descriptorRef>
+ <descriptorRef>full</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,305 @@
+package org.nuiton.jrst;
+
+import info.monitorenter.cpdetector.io.ASCIIDetector;
+import info.monitorenter.cpdetector.io.ByteOrderMarkDetector;
+import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
+import info.monitorenter.cpdetector.io.JChardetFacade;
+import info.monitorenter.cpdetector.io.ParsingDetector;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.tmatesoft.svn.core.SVNAuthenticationException;
+import org.tmatesoft.svn.core.SVNDepth;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNProperty;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNCommitClient;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.wc.SVNUpdateClient;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+
+/**
+ * @author geoffroy lorieux
+ */
+public class HelloServlet extends HttpServlet {
+
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ * Do checkout on a private or not scm and call modification jsp page
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ try {
+
+// First Part Svn checkout and JSP call
+ log.debug("--------------------------");
+ log.debug("Connection to SCMWebEditor");
+ log.debug("--------------------------");
+ System.setProperty("file.encoding", "UTF-8");
+ HttpSession httpSession = request.getSession(true);
+
+ if (request.getParameter("adresse").startsWith("scm:svn:") == true){
+
+ log.debug("La chaine debute par scm:svn");
+ String adress = request.getParameter("adresse").replace("scm:svn:", "");
+ log.debug("Le new chaine est : "+adress);
+ }
+
+// svnSession object creation if doesn't already exist
+ SvnSession svnSess = (httpSession.getAttribute("myInfo") == null?
+ new SvnSession((request.getParameter("adresse").startsWith("scm:svn:") == true ? request.getParameter("adresse").replace("scm:svn:", "") : request.getParameter("adresse")),
+ request.getParameter("file_name"), request.getParameter("project_url"),
+ null, null, (File) getServletContext().getAttribute("javax.servlet.context.tempdir"),httpSession.getId()) :
+ (SvnSession) httpSession.getAttribute("myInfo"));
+
+ PrintWriter out = response.getWriter();
+
+// UTF-8 Test
+ if (SVNProperty.isUTF8(svnSess.getSvnOption().getNativeCharset()) == true){
+ log.debug("Je suis en utf8");
+ } else {
+ log.debug("Je ne suis pas en utf8");
+ }
+
+ httpSession.setAttribute("myInfo", svnSess);
+// Tempdir creation
+
+ log.debug("Creating temporary directory on: " + svnSess.getCheckoutdir());
+ svnSess.getCheckoutdir().mkdir();
+
+// doCheckout declaration
+
+ DAVRepositoryFactory.setup();
+ SVNUpdateClient upclient = new SVNUpdateClient(svnSess.getManager(), svnSess.getSvnOption());
+
+// Checkout svn and file organisation
+ try{
+ log.debug("Do Checkout");
+ upclient.doCheckout(svnSess.getRemoteUrl(), svnSess.getCheckoutdir(),
+ SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.FILES, false);
+ } catch (SVNAuthenticationException authexep) {
+// if svn authentication failed user is redirected on login page
+ log.debug("Private SCM on reading");
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+ request.setAttribute("adresse", svnSess.getSvnPath());
+ request.setAttribute("file_name", svnSess.getFileName());
+ request.setAttribute("projectUrl", svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/PrivateSvnRedirect.jsp");
+ requestDispacher.forward(request, response);
+ return;
+ }
+ log.debug("Checkout done");
+
+ File file_in_dir = new File(svnSess.getCheckoutdir(), svnSess.getFileName());
+ String original_text = FileUtils.readFileToString(file_in_dir);
+
+// JSP data transfert
+ request.setAttribute("OrigText", original_text);
+ request.setAttribute("InvalidateMaxTime", (httpSession.getMaxInactiveInterval()/60));
+ log.debug("Invalidate time is :"+(httpSession.getMaxInactiveInterval()/60));
+ request.setAttribute("IsLogin", (svnSess.getLogin() != null && svnSess.getPassword() != null ? true : false));
+ log.debug("IsLogin : "+(svnSess.getLogin() != null && svnSess.getPassword() != null ? true : false));
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/ModificationViewer.jsp");
+// End on first part
+ requestDispacher.forward(request, response);
+ out.close();
+ } catch (SVNException ex) {
+ Logger.getLogger(HelloServlet.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ * Receve the new text and commit it to scm
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException{
+ try {
+
+// Second Part Client response and SVN commit
+ System.setProperty("file.encoding", "UTF-8");
+ HttpSession httpSession = request.getSession(true);
+ SvnSession svnSess = (SvnSession) httpSession.getAttribute("myInfo");
+
+// Resetting authentification information and manager
+ svnSess.setLogin(svnSess.getLogin() != null ? svnSess.getLogin() : request.getParameter("username"));
+ svnSess.setPassword(svnSess.getPassword() != null ? svnSess.getPassword() : request.getParameter("pw"));
+ svnSess.setAuthManager(SVNWCUtil.createDefaultAuthenticationManager(svnSess.getCheckoutdir(), svnSess.getLogin(), svnSess.getPassword(), false));
+ svnSess.setManager(SVNClientManager.newInstance(svnSess.getSvnOption(), svnSess.getAuthManager()));
+
+ File pathToFile = new File(svnSess.getCheckoutdir(), svnSess.getFileName());
+
+ SVNCommitClient commitClient = new SVNCommitClient(svnSess.getManager(), svnSess.getSvnOption());
+ FileUtils.writeStringToFile(pathToFile, request.getParameter("Mytext"));
+
+ List<File> list = new java.util.ArrayList<File>(1);
+ list.add(0, pathToFile);
+
+ list = convertToUnicode(list);
+
+ File[] tabFile = new File[1];
+ tabFile[0] = pathToFile;
+// Sending Data to SVN
+ try{
+ log.debug("Try to Commit");
+ commitClient.doCommit(tabFile, false, request.getParameter("Commit_message"), null, null, false, true, SVNDepth.FILES);
+ } catch (SVNAuthenticationException authexep) {
+// if authentication failed edition page is reload form user's relogin
+ log.debug("Bad Login or Password");
+ response.setStatus(401);
+ request.setAttribute("svnPath_url", svnSess.getSvnPath());
+ request.setAttribute("fileName_url", svnSess.getFileName());
+ request.setAttribute("Redirection_url", svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/Error.jsp");
+ requestDispacher.forward(request, response);
+ return;
+ }
+// if commit success user is redirect on the project page
+ log.debug("Commit success");
+ request.setAttribute("Redirection_url", svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/Redirect.jsp");
+// Deleting temp directory
+
+ log.debug("Deleting temporary directory : " + svnSess.getCheckoutdir());
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+// End of Second part
+
+ requestDispacher.forward(request, response);
+ log.debug("Exit RSTEditor");
+
+ } catch (SVNException ex) {
+ Logger.getLogger(HelloServlet.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ protected static CodepageDetectorProxy detector;
+ private static final Log log = LogFactory.getLog(HelloServlet.class);
+
+ protected static CodepageDetectorProxy getCodepageDetector() {
+
+ if (detector == null) {
+ detector = CodepageDetectorProxy.getInstance(); // A singleton.
+
+ // Add the implementations of info.monitorenter.cpdetector.io.ICodepageDetector:
+ // This one is quick if we deal with unicode codepages:
+ detector.add(new ByteOrderMarkDetector());
+ // The first instance delegated to tries to detect the meta charset attribut in html pages.
+ detector.add(new ParsingDetector(true)); // be verbose about parsing.
+ // This one does the tricks of exclusion and frequency detection, if first implementation is
+ // unsuccessful:
+ detector.add(JChardetFacade.getInstance()); // Another singleton.
+ detector.add(ASCIIDetector.getInstance()); // Fallback, see javadoc.
+ }
+ return detector;
+ }
+
+
+ /**
+ * Convert all files to UTF-8.
+ *
+ * @param files fiels to convert
+ * @return converted file list
+ */
+ public static List<File> convertToUnicode(List<File> files) {
+
+ CodepageDetectorProxy myDetector = getCodepageDetector();
+
+ for (File file : files) {
+ try {
+ Charset charset = myDetector.detectCodepage(file.toURI().toURL());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Charset for " + file.getAbsolutePath() + " is " + charset);
+ }
+
+ if (charset != null && !charset.name().equalsIgnoreCase("UTF-8")) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Convert " + file.getAbsolutePath() + " to unicode");
+ }
+
+ File tmpFile = File.createTempFile(file.getName(), ".copy");
+ tmpFile.deleteOnExit();
+
+ // direct copy
+ InputStream is = new FileInputStream(file);
+ OutputStream os = new FileOutputStream(tmpFile);
+ try {
+ IOUtils.copy(is, os);
+ }
+ finally {
+ is.close();
+ os.close();
+ }
+
+ // copy using cp transaltion
+ is = new FileInputStream(tmpFile);
+ os = new FileOutputStream(file);
+ Reader ir = new InputStreamReader(is, charset);
+ Writer ow = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ try {
+ IOUtils.copy(ir, ow);
+ }
+ finally {
+ ir.close();
+ ow.close();
+ is.close();
+ os.close();
+ }
+
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("File " + file.getAbsolutePath() + " already in unicode : skip");
+ }
+ }
+ } catch (MalformedURLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ }
+
+ }
+
+ return files;
+ }
+}
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,180 @@
+package org.nuiton.jrst;
+
+import info.monitorenter.cpdetector.io.ASCIIDetector;
+import info.monitorenter.cpdetector.io.ByteOrderMarkDetector;
+import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
+import info.monitorenter.cpdetector.io.JChardetFacade;
+import info.monitorenter.cpdetector.io.ParsingDetector;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.List;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author geoffroy lorieux
+ */
+public class PreviewServlet extends HttpServlet {
+
+ /**
+ * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ log.debug("je suis dans la previewservlet");
+ HttpSession httpSession = request.getSession(true);
+ File tmp_dir = (File) getServletContext().getAttribute("javax.servlet.context.tempdir");
+ log.debug("Le tmp dir est :" + tmp_dir);
+ log.debug("Le content type est : " + request.getContentType());
+// Text recuperation
+ String myData = request.getParameter("text");
+// Text formating and tempfile creating
+ String myDataWithoutcrlf = myData.replace("\r", "");
+ File file_in_dir_copy = new File(tmp_dir, "copy"+httpSession.getId()+".rst");
+ File http_file = new File(tmp_dir, "preview"+httpSession.getId()+".html");
+ file_in_dir_copy.createNewFile();
+ http_file.createNewFile();
+ FileUtils.writeStringToFile(file_in_dir_copy, myDataWithoutcrlf);
+ List<File> list = new java.util.ArrayList<File>(1);
+ list.add(0, file_in_dir_copy);
+ list = convertToUnicode(list);
+
+ File copy = new File(tmp_dir, "copy"+httpSession.getId()+".rst");
+// Using jrst for generate html document
+ try{
+ JRST.generate(JRST.TYPE_HTML, copy, http_file, JRST.Overwrite.ALLTIME);
+ log.debug("generate okai");
+ } catch (Exception eee) {
+ log.debug("Bad RST file");
+ response.setStatus(406);
+ return;
+ }
+ copy.delete();
+// Sending html content to pop-up preview page
+ response.setContentType("text/html");
+ PrintWriter ret = response.getWriter();
+ ret.print(FileUtils.readFileToString(http_file));
+ http_file.delete();
+ }
+
+ protected static CodepageDetectorProxy detector;
+ private static final Log log = LogFactory.getLog(PreviewServlet.class);
+
+ protected static CodepageDetectorProxy getCodepageDetector() {
+
+ if (detector == null) {
+ detector = CodepageDetectorProxy.getInstance(); // A singleton.
+
+ // Add the implementations of info.monitorenter.cpdetector.io.ICodepageDetector:
+ // This one is quick if we deal with unicode codepages:
+ detector.add(new ByteOrderMarkDetector());
+ // The first instance delegated to tries to detect the meta charset attribut in html pages.
+ detector.add(new ParsingDetector(true)); // be verbose about parsing.
+ // This one does the tricks of exclusion and frequency detection, if first implementation is
+ // unsuccessful:
+ detector.add(JChardetFacade.getInstance()); // Another singleton.
+ detector.add(ASCIIDetector.getInstance()); // Fallback, see javadoc.
+ }
+ return detector;
+ }
+
+
+ /**
+ * Convert all files to UTF-8.
+ *
+ * @param files fiels to convert
+ * @return converted file list
+ */
+ public static List<File> convertToUnicode(List<File> files) {
+
+ CodepageDetectorProxy myDetector = getCodepageDetector();
+
+ for (File file : files) {
+ try {
+ Charset charset = myDetector.detectCodepage(file.toURI().toURL());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Charset for " + file.getAbsolutePath() + " is " + charset);
+ }
+
+ if (charset != null && !charset.name().equalsIgnoreCase("UTF-8")) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Convert " + file.getAbsolutePath() + " to unicode");
+ }
+
+ File tmpFile = File.createTempFile(file.getName(), ".copy");
+ tmpFile.deleteOnExit();
+
+ // direct copy
+ InputStream is = new FileInputStream(file);
+ OutputStream os = new FileOutputStream(tmpFile);
+ try {
+ IOUtils.copy(is, os);
+ }
+ finally {
+ is.close();
+ os.close();
+ }
+
+ // copy using cp transaltion
+ is = new FileInputStream(tmpFile);
+ os = new FileOutputStream(file);
+ Reader ir = new InputStreamReader(is, charset);
+ Writer ow = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ try {
+ IOUtils.copy(ir, ow);
+ }
+ finally {
+ ir.close();
+ ow.close();
+ is.close();
+ os.close();
+ }
+
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("File " + file.getAbsolutePath() + " already in unicode : skip");
+ }
+ }
+ } catch (MalformedURLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ }
+
+ }
+
+ return files;
+ }
+}
+
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,45 @@
+package org.nuiton.jrst;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+/**
+ * @author geoffroy lorieux
+ */
+public class PrivateSvnServlet extends HttpServlet{
+
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ log.debug("New Log setting");
+ HttpSession httpSession = request.getSession(true);
+ System.setProperty("file.encoding", "UTF-8");
+ PrintWriter out = response.getWriter();
+ SvnSession svnSess = (SvnSession) httpSession.getAttribute("myInfo");
+// Resetting User Information
+ svnSess.setLogin(request.getParameter("username"));
+ svnSess.setPassword(request.getParameter("pw"));
+ svnSess.setAuthManager(SVNWCUtil.createDefaultAuthenticationManager(svnSess.getCheckoutdir(),svnSess.getLogin(), svnSess.getPassword(), false));
+ svnSess.setManager(SVNClientManager.newInstance(svnSess.getSvnOption(), svnSess.getAuthManager()));
+ httpSession.setAttribute("myInfo", svnSess);
+// Recalling helloservlet with user information stock on session
+ request.setAttribute("Redirect_url",
+ "http://localhost:8080/nuiton-rstedit/hello?adresse="+svnSess.getSvnPath()+"&"+"file_name="+svnSess.getFileName()+"&"+"projectUrl="+svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/Recall.jsp");
+
+ requestDispacher.forward(request, response);
+ out.close();
+ }
+ private static final Log log = LogFactory.getLog(PrivateSvnServlet.class);
+}
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,129 @@
+package org.nuiton.jrst;
+
+import java.io.File;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNProperty;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
+import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+class SvnSession {
+
+ public ISVNAuthenticationManager getAuthManager() {
+ return authManager;
+ }
+
+ public void setAuthManager(ISVNAuthenticationManager authManager) {
+ this.authManager = authManager;
+ }
+
+ public File getCheckoutdir() {
+ return checkoutdir;
+ }
+
+ public void setCheckoutdir(File checkoutdir) {
+ this.checkoutdir = checkoutdir;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getLogin() {
+ return login;
+ }
+
+ public void setLogin(String login) {
+ this.login = login;
+ }
+
+ public SVNClientManager getManager() {
+ return manager;
+ }
+
+ public void setManager(SVNClientManager manager) {
+ this.manager = manager;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getProjectUrl() {
+ return projectUrl;
+ }
+
+ public void setProjectUrl(String projectUrl) {
+ this.projectUrl = projectUrl;
+ }
+
+ public SVNURL getRemoteUrl() {
+ return remoteUrl;
+ }
+
+ public void setRemoteUrl(SVNURL remoteUrl) {
+ this.remoteUrl = remoteUrl;
+ }
+
+ public DefaultSVNOptions getSvnOption() {
+ return svnOption;
+ }
+
+ public void setSvnOption(DefaultSVNOptions svnOption) {
+ this.svnOption = svnOption;
+ }
+
+ public String getSvnPath() {
+ return svnPath;
+ }
+
+ public void setSvnPath(String svnPath) {
+ this.svnPath = svnPath;
+ }
+
+ public File getTmpDir() {
+ return tmpDir;
+ }
+
+ public void setTmpDir(File tmpDir) {
+ this.tmpDir = tmpDir;
+ }
+
+ String svnPath;// svn path without fileName
+ String fileName;// fileName of modif file
+ String projectUrl;// Projectname
+ String login;// user's login
+ String password;// user's password
+ File tmpDir;// Temp directory path
+ File checkoutdir;// Temp directory for checkout
+ SVNURL remoteUrl;// url of svn path
+ ISVNAuthenticationManager authManager;// AuthenticationManager with login and password
+ DefaultSVNOptions svnOption;// svn default option
+ SVNClientManager manager;
+
+ SvnSession(String svnPath, String fileName, String projectUrl, String login, String password, File tmpDir, String id) throws SVNException {
+ super();
+ this.svnPath = svnPath;
+ this.fileName = fileName;
+ this.projectUrl = projectUrl;
+ this.login = login;
+ this.password = password;
+ this.tmpDir = tmpDir;
+ this.checkoutdir = new File(this.tmpDir, "temp_rst"+id);
+ this.remoteUrl = SVNURL.parseURIEncoded(svnPath);
+ this.authManager = SVNWCUtil.createDefaultAuthenticationManager(this.checkoutdir, this.login, this.password, false);
+ this.svnOption = SVNWCUtil.createDefaultOptions(this.checkoutdir, false);
+ this.svnOption.setPropertyValue(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_LF);
+ this.manager = SVNClientManager.newInstance(this.svnOption, this.authManager);
+ }
+}
Added: nuiton-rstedit/src/main/resources/log4j.properties
===================================================================
--- nuiton-rstedit/src/main/resources/log4j.properties (rev 0)
+++ nuiton-rstedit/src/main/resources/log4j.properties 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,30 @@
+# Global logging configuration
+log4j.rootLogger=DEBUG, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+# File output...
+#log4j.appender.fileout=org.apache.log4j.FileAppender
+#log4j.appender.fileout.File=jtimer.log
+#log4j.appender.fileout.Append=true
+#log4j.appender.fileout.Threshold=DEBUG
+#log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
+#log4j.appender.fileout.layout.ConversionPattern=%5p (%F:%L) %m%n
+
+# Rolling appender
+#log4j.appender.rolling=org.apache.log4j.RollingFileAppender
+#log4j.appender.rolling.File=jtimer.log
+#log4j.appender.rolling.MaxFileSize=100KB
+#log4j.appender.rolling.Append=true
+#log4j.appender.rolling.MaxBackupIndex=30
+#log4j.appender.rolling.Threshold=INFO
+#log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
+#log4j.appender.rolling.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+# package level
+#log4j.logger.org.chorem.jtimer=DEBUG
+#log4j.logger.org.chorem.jtimer.ws=DEBUG
+#log4j.logger.org.chorem.jtimer.ui.report=DEBUG
Added: nuiton-rstedit/src/main/webapp/Error.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Error.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Error.jsp 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,22 @@
+<%--
+ Document : Error
+ Created on : 15 sept. 2009, 12:22:29
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Error</title>
+ <meta http-equiv="Refresh" content="2;
+ url=http://localhost:8080/nuiton-rstedit/hello?adresse=<%=request.getAttribute("Svnpath_url")%>&file_name=<%=request.getAttribute("Filename_url")%>&project_url=<%=request.getAttribute("Redirection_url")%>">
+ </head>
+ <body>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>Bad Login or Password. Please Wait.</p>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/GereFormSize.js
===================================================================
--- nuiton-rstedit/src/main/webapp/GereFormSize.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/GereFormSize.js 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,43 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+
+function countLines(strtocount, cols)
+ {
+ var hard_lines = 1;
+ var last = 0;
+ while ( true )
+ {
+ last = strtocount.indexOf("\n", last+1);
+ hard_lines ++;
+ if ( last == -1 )
+ {
+ break;
+ }
+ }
+ var soft_lines = Math.round(strtocount.length / (cols-1));
+ var hard = eval("hard_lines " + unescape("%3e") + "soft_lines;");
+ if ( hard )
+ {
+ soft_lines = hard_lines;
+ }
+ return soft_lines;
+ }
+function cleanForm()
+ {
+ var the_form = document.forms[0];
+ for ( var x in the_form )
+ {
+ if ( ! the_form[x] )
+ {
+ continue;
+ }
+ if( typeof the_form[x].rows != "number" )
+ {
+ continue;
+ }
+ the_form[x].rows = countLines(the_form[x].value,the_form[x].cols) +1;
+ }
+ setTimeout("cleanForm();", 300);
+ }
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/GereSession.js
===================================================================
--- nuiton-rstedit/src/main/webapp/GereSession.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/GereSession.js 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,41 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+function rappelSession(minutes)
+{
+ var msg='Your session expire on '+minutes+' minute';
+ if(minutes>1)
+ {
+ msg+='s';
+ }
+ msg+='.\nDo you want to reload this page ?';
+
+ if(confirm(msg))
+ {
+ location.reload();
+ }
+}
+
+/**
+ * affiche une alerte sur l'expiration de la session et redirige vers une autre page
+ */
+function expirationSession()
+{
+ alert("Your session has expire. Please relogin");
+ window.history.back(-1);
+}
+
+/**
+ * affiche des avertissements sur le délai d'expiration de la session :
+ * - un premier au bout de (expiration-rappel) minutes (par ex. : 20-3 = 17 minutes)
+ * - un second au bout de (expiration) minutes (par ex. : 20 minutes)
+ */
+function geresession(expiration, rappel)
+{
+ // affichage du rappel
+ var chronoRappel=setTimeout('rappelSession('+rappel+')', (expiration-rappel)*60*1000);
+
+ // une fois le rappel affiché, on avertit uniquement de l'expiration
+ var chronoExpiration=setTimeout('expirationSession()', (expiration-1)*60*1000);
+}
Added: nuiton-rstedit/src/main/webapp/ModificationViewer.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/ModificationViewer.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/ModificationViewer.jsp 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,45 @@
+<%--
+ Document : ModificationViewer
+ Created on : 10 sept. 2009, 13:43:11
+ Author : glorieux
+--%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>SCMWebEditor</title>
+
+ </head>
+<body onload="cleanForm(); geresession(<%=request.getAttribute("InvalidateMaxTime")%>, 5);">
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <center><h2><p>Welcome on SCMWebEditor</p></h2><h4><p>For any Problem with RestruturedText visit <a href="http://docutils.sourceforge.net/rst.html">RST documentation website</a>.</p></h4></center>
+ <center><form method="post" action="/nuiton-rstedit/hello">
+ <script src="GereFormSize.js"></script>
+ <textarea name="Mytext" id="Mytext" rows="20" cols="150"><%=request.getAttribute("OrigText")%></textarea>
+ <script src="Preview.js"></script>
+ <script src="Saver.js"></script>
+ <script src="GereSession.js"></script>
+ <script src="cancelRedirect.js"></script>
+ <p>Commit Message: <input type="text" name="Commit_message"/></p>
+ <%if (request.getAttribute("IsLogin").equals(false) == true){
+ %><p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12></label>
+ <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12></label> </p><%
+ } else {
+ %><input type="hidden" NAME=username><input type="hidden" NAME=pw><%
+ }%>
+ <input type="hidden" name="Orig_text" value="<%=request.getAttribute("OrigText")%>"/>
+ <input type="button" value="Save and Continue Editing" name="SaveandC" onclick="javascript:saver(this.form.Mytext, this.form.username, this.form.pw, this.form.Commit_message, this.form.Orig_text);"/>
+ <input type="submit" value="Save and Quit" name="Save"/>
+ <input type="button" value="Preview" name="Preview" onclick="javascript:preview(this.form.Mytext);"/>
+ <input type="reset" value="Reset" name="Reset" />
+ <input type="button" value="Exit" name="Cancel" onclick="javascript:cancelRedirect();"/>
+ </form></center>
+
+ <h4><p>Older Text Preview :</p></h4>
+ <pre><%=request.getAttribute("OrigText")%></pre>
+</body>
+</html>
Added: nuiton-rstedit/src/main/webapp/Preview.js
===================================================================
--- nuiton-rstedit/src/main/webapp/Preview.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/Preview.js 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,56 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+function createRequestObject()
+{
+ var req;
+ if(window.XMLHttpRequest)
+ {
+ //For Firefox, Safari, Opera
+ req = new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ //For IE 5+
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ else
+ {
+ //Error for an old browser
+ alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
+ }
+ return req;
+}
+
+//Make the XMLHttpRequest Object
+var http= createRequestObject();
+
+function sendRequest(method, url, text)
+{
+
+ http.open(method, url, true);
+ http.onreadystatechange = handleResponse;
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.send("text="+text.value);
+}
+
+function handleResponse()
+{
+ if(http.readyState == 4 && http.status != 406)
+ {
+ var response = http.responseText;
+ var wind = window.open("", "Preview", "scrollbars=yes,resizable=yes,status=yes");
+ wind.document.body.innerHTML = response;
+ }
+ else if (http.readyState == 4 && http.status == 406)
+ {
+ alert("Bad RestructuredText file format please correct it.");
+ }
+}
+
+function preview(my_text)
+{
+ sendRequest("POST", "http://localhost:8080/nuiton-rstedit/previewservlet", my_text);
+}
+
Added: nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,29 @@
+<%--
+ Document : PrivateSvnRedirect
+ Created on : 30 sept. 2009, 14:05:43
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Private Scm</title>
+ </head>
+ <body><form method="post" action="/nuiton-rstedit/privatesvnservlet">
+ <script src="cancelRedirect.js"></script>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>You try to access a Private SCM. Please login</p>
+ <p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12></label>
+ <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12></label></p>
+ <input type="submit" value="Submit" name="Save"/>
+ <input type="button" value="Exit" name="Cancel" onclick="cancelRedirect();"/>
+ <input type="hidden" name="adresse" value="<%=request.getAttribute("adresse")%>"/>
+ <input type="hidden" name="file_name" value="<%=request.getAttribute("file_name")%>"/>
+ <input type="hidden" name="project_url" value="<%=request.getAttribute("project_url")%>"/>
+ </form>
+ </body>
+</html>
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/Recall.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Recall.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Recall.jsp 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,17 @@
+<%--
+ Document : Recall
+ Created on : 30 sept. 2009, 17:05:40
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Redirect...</title>
+ <meta http-equiv="Refresh" content="0; url=<%=request.getAttribute("Redirect_url")%>">
+ </head>
+</html>
Added: nuiton-rstedit/src/main/webapp/Redirect.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Redirect.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Redirect.jsp 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,23 @@
+<%--
+ Document : Redirect
+ Created on : 10 sept. 2009, 13:43:11
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Redirection...</title>
+ <meta http-equiv="Refresh" content="2; url=<%=request.getAttribute("Redirection_url")%>">
+ </head>
+ <body>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>Thank you using RSTEditor</p>
+ <p>You should be transferred automatically to the new page. If
+not please <a href="<%=request.getAttribute("Redirection_url")%>">click this link</a>.</p>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/Saver.js
===================================================================
--- nuiton-rstedit/src/main/webapp/Saver.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/Saver.js 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,63 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+function createRequestObject()
+{
+ var req;
+ if(window.XMLHttpRequest)
+ {
+ //For Firefox, Safari, Opera
+ req = new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ //For IE 5+
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ else
+ {
+ //Error for an old browser
+ alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
+ }
+ return req;
+}
+
+//Make the XMLHttpRequest Object
+var http= createRequestObject();
+
+function sendReq(method, url, text, login, pass, message)
+{
+ http.open(method, url, true);
+ http.onreadystatechange = handleResp;
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.send("Mytext="+text.value+"&username="+login.value+"&pw="+pass.value+"&Commit_message="+message.value);
+}
+
+function handleResp()
+{
+ if(http.readyState == 4 && http.status != 401)
+ {
+ alert("Save Ok. This page will be reloaded shortly.");
+ window.location.reload(true);
+ }
+ else if (http.readyState == 4 && http.status == 401)
+ {
+ alert("Bad login or password please recheck.");
+ }
+}
+
+function saver(my_text, login, pass, message, orig_text)
+{
+ if (my_text.value != orig_text.value)
+ {
+ if (confirm("Do you really want to save?"))
+ {
+ sendReq("POST", "http://localhost:8080/nuiton-rstedit/hello", my_text, login, pass, message);
+ }
+ }
+ else
+ {
+ alert("File don't need to be save.");
+ }
+}
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/WEB-INF/web.xml
===================================================================
--- nuiton-rstedit/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ nuiton-rstedit/src/main/webapp/WEB-INF/web.xml 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
+ <servlet>
+ <servlet-name>HelloServlet</servlet-name>
+ <servlet-class>org.nuiton.jrst.HelloServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>PreviewServlet</servlet-name>
+ <servlet-class>org.nuiton.jrst.PreviewServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>Saveservlet</servlet-name>
+ <servlet-class>Saveservlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>PrivateSvnServlet</servlet-name>
+ <servlet-class>org.nuiton.jrst.PrivateSvnServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>HelloServlet</servlet-name>
+ <url-pattern>/hello</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>PreviewServlet</servlet-name>
+ <url-pattern>/previewservlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Saveservlet</servlet-name>
+ <url-pattern>/saveservlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>PrivateSvnServlet</servlet-name>
+ <url-pattern>/privatesvnservlet</url-pattern>
+ </servlet-mapping>
+ </web-app>
Added: nuiton-rstedit/src/main/webapp/cancelRedirect.js
===================================================================
--- nuiton-rstedit/src/main/webapp/cancelRedirect.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/cancelRedirect.js 2009-10-05 15:04:40 UTC (rev 270)
@@ -0,0 +1,11 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+
+function cancelRedirect()
+ {
+ if (confirm("Exit SCMWebEditor ?")){
+ window.history.back(-1);
+ }
+ }
\ No newline at end of file
1
0
Author: glorieux
Date: 2009-10-05 17:03:55 +0200 (Mon, 05 Oct 2009)
New Revision: 269
Removed:
nuiton-rstedit/
Log:
1
0
r268 - / nuiton-rstedit nuiton-rstedit/src nuiton-rstedit/src/main nuiton-rstedit/src/main/java nuiton-rstedit/src/main/java/org nuiton-rstedit/src/main/java/org/nuiton nuiton-rstedit/src/main/java/org/nuiton/jrst nuiton-rstedit/src/main/resources nuiton-rstedit/src/main/webapp nuiton-rstedit/src/main/webapp/WEB-INF nuiton-rstedit/src/test
by glorieux@users.nuiton.org 02 Oct '09
by glorieux@users.nuiton.org 02 Oct '09
02 Oct '09
Author: glorieux
Date: 2009-10-02 12:19:20 +0200 (Fri, 02 Oct 2009)
New Revision: 268
Added:
nuiton-rstedit/
nuiton-rstedit/LICENSE.txt
nuiton-rstedit/README.txt
nuiton-rstedit/changelog.txt
nuiton-rstedit/pom.xml
nuiton-rstedit/src/
nuiton-rstedit/src/main/
nuiton-rstedit/src/main/java/
nuiton-rstedit/src/main/java/org/
nuiton-rstedit/src/main/java/org/nuiton/
nuiton-rstedit/src/main/java/org/nuiton/jrst/
nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java
nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java
nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java
nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java
nuiton-rstedit/src/main/resources/
nuiton-rstedit/src/main/resources/log4j.properties
nuiton-rstedit/src/main/webapp/
nuiton-rstedit/src/main/webapp/Error.jsp
nuiton-rstedit/src/main/webapp/GereFormSize.js
nuiton-rstedit/src/main/webapp/GereSession.js
nuiton-rstedit/src/main/webapp/ModificationViewer.jsp
nuiton-rstedit/src/main/webapp/Preview.js
nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp
nuiton-rstedit/src/main/webapp/Recall.jsp
nuiton-rstedit/src/main/webapp/Redirect.jsp
nuiton-rstedit/src/main/webapp/Saver.js
nuiton-rstedit/src/main/webapp/WEB-INF/
nuiton-rstedit/src/main/webapp/WEB-INF/web.xml
nuiton-rstedit/src/main/webapp/cancelRedirect.js
nuiton-rstedit/src/test/
nuiton-rstedit/src/test/java/
Log:
Added: nuiton-rstedit/LICENSE.txt
===================================================================
--- nuiton-rstedit/LICENSE.txt (rev 0)
+++ nuiton-rstedit/LICENSE.txt 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: nuiton-rstedit/README.txt
===================================================================
--- nuiton-rstedit/README.txt (rev 0)
+++ nuiton-rstedit/README.txt 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Added: nuiton-rstedit/pom.xml
===================================================================
--- nuiton-rstedit/pom.xml (rev 0)
+++ nuiton-rstedit/pom.xml 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,173 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom</artifactId>
+ <version>1.0.2</version>
+ </parent>
+
+ <artifactId>nuiton-rstedit</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.tmatesoft.svnkit</groupId>
+ <artifactId>svnkit</artifactId>
+ <version>1.2.3.5521</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.jrst</groupId>
+ <artifactId>jrst</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.cpdetector</groupId>
+ <artifactId>cpdetector</artifactId>
+ <version>1.0.7</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>codelutin-repository</id>
+ <name>CodeLutinRepository</name>
+ <url>http://lutinbuilder.labs.libre-entreprise.org/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ </repository>
+ </repositories>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton-rstedit</name>
+ <description>.
+ </description>
+ <inceptionYear>2009</inceptionYear>
+ <url>http://maven-site.nuiton.org/${project.artifactId}</url>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>war</packaging>
+
+ <properties>
+
+
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.jrst</groupId>
+ <artifactId>doxia-module-jrst</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ </build>
+
+ <!-- Source control management. -->
+ <scm>
+ <connection>scm:svn:http://svn.nuiton.org/svn/mavenpom/nuiton-rstedit/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/mavenpom/nuiton-rstedit/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/mavenpom/nuiton-rstedit/trunk</url>
+ </scm>
+
+ <profiles>
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+
+ <plugins>
+
+ <!-- launch in a release the assembly automaticly -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-assemblies</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>false</attach>
+ <descriptorRefs>
+ <descriptorRef>deps</descriptorRef>
+ <descriptorRef>full</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/HelloServlet.java 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,292 @@
+package org.nuiton.jrst;
+
+import info.monitorenter.cpdetector.io.ASCIIDetector;
+import info.monitorenter.cpdetector.io.ByteOrderMarkDetector;
+import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
+import info.monitorenter.cpdetector.io.JChardetFacade;
+import info.monitorenter.cpdetector.io.ParsingDetector;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.tmatesoft.svn.core.SVNAuthenticationException;
+import org.tmatesoft.svn.core.SVNDepth;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNProperty;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNCommitClient;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.wc.SVNUpdateClient;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+
+/**
+ * @author geoffroy lorieux
+ */
+public class HelloServlet extends HttpServlet {
+
+
+ // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ try {
+
+// First Part Svn checkout and JSP call
+ log.debug("--------------------------");
+ log.debug("Connection to SCMWebEditor");
+ log.debug("--------------------------");
+ System.setProperty("file.encoding", "UTF-8");
+ HttpSession httpSession = request.getSession(true);
+
+ log.debug("L'url du project est : "+request.getParameter("projectUrl"));
+
+ SvnSession svnSess = (httpSession.getAttribute("myInfo") == null?
+ new SvnSession(request.getParameter("adresse"), request.getParameter("file_name"), request.getParameter("project_url"),
+ null, null, (File) getServletContext().getAttribute("javax.servlet.context.tempdir"),httpSession.getId()) :
+ (SvnSession) httpSession.getAttribute("myInfo"));
+
+ PrintWriter out = response.getWriter();
+
+// UTF-8 Test
+ if (SVNProperty.isUTF8(svnSess.getSvnOption().getNativeCharset()) == true){
+ log.debug("Je suis en utf8");
+ } else {
+ log.debug("Je ne suis pas en utf8");
+ }
+
+ httpSession.setAttribute("myInfo", svnSess);
+// Tempdir creation
+
+ log.debug("Creating temporary directory on: " + svnSess.getCheckoutdir());
+ svnSess.getCheckoutdir().mkdir();
+
+// doCheckout declaration
+
+ DAVRepositoryFactory.setup();
+ SVNUpdateClient upclient = new SVNUpdateClient(svnSess.getManager(), svnSess.getSvnOption());
+
+// Checkout svn and file organisation
+ try{
+ log.debug("Do Checkout");
+ upclient.doCheckout(svnSess.getRemoteUrl(), svnSess.getCheckoutdir(),
+ SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.FILES, false);
+ } catch (SVNAuthenticationException authexep) {
+ log.debug("Private SCM on reading");
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+ request.setAttribute("adresse", svnSess.getSvnPath());
+ request.setAttribute("file_name", svnSess.getFileName());
+ request.setAttribute("projectUrl", svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/PrivateSvnRedirect.jsp");
+ requestDispacher.forward(request, response);
+ return;
+ }
+ log.debug("Checkout done");
+ File file_in_dir = new File(svnSess.getCheckoutdir(), svnSess.getFileName());
+ String original_text = FileUtils.readFileToString(file_in_dir);
+
+// JSP data transfert
+ request.setAttribute("OrigText", original_text);
+ request.setAttribute("InvalidateMaxTime", (httpSession.getMaxInactiveInterval()/60));
+ log.debug("Invalidate time is :"+(httpSession.getMaxInactiveInterval()/60));
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/ModificationViewer.jsp");
+// End on first part
+ requestDispacher.forward(request, response);
+ out.close();
+ } catch (SVNException ex) {
+ Logger.getLogger(HelloServlet.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException{
+ try {
+
+// Second Part Client response and SVN commit
+ System.setProperty("file.encoding", "UTF-8");
+ HttpSession httpSession = request.getSession(true);
+ SvnSession svnSess = (SvnSession) httpSession.getAttribute("myInfo");
+
+// Resetting authentification information and manager
+ svnSess.setLogin(svnSess.getLogin() != null ? svnSess.getLogin() : request.getParameter("username"));
+ svnSess.setPassword(svnSess.getPassword() != null ? svnSess.getPassword() : request.getParameter("pw"));
+ svnSess.setAuthManager(SVNWCUtil.createDefaultAuthenticationManager(svnSess.getCheckoutdir(), svnSess.getLogin(), svnSess.getPassword(), false));
+ svnSess.setManager(SVNClientManager.newInstance(svnSess.getSvnOption(), svnSess.getAuthManager()));
+
+ File pathToFile = new File(svnSess.getCheckoutdir(), svnSess.getFileName());
+
+ SVNCommitClient commitClient = new SVNCommitClient(svnSess.getManager(), svnSess.getSvnOption());
+ FileUtils.writeStringToFile(pathToFile, request.getParameter("Mytext"));
+
+ List<File> list = new java.util.ArrayList<File>(1);
+ list.add(0, pathToFile);
+
+ list = convertToUnicode(list);
+
+ File[] tabFile = new File[1];
+ tabFile[0] = pathToFile;
+// Sending Data to SVN
+ try{
+ log.debug("Try to Commit");
+ commitClient.doCommit(tabFile, false, request.getParameter("Commit_message"), null, null, false, true, SVNDepth.FILES);
+ } catch (SVNAuthenticationException authexep) {
+ log.debug("Bad Login or Password");
+ response.setStatus(401);
+ request.setAttribute("svnPath_url", svnSess.getSvnPath());
+ request.setAttribute("fileName_url", svnSess.getFileName());
+ request.setAttribute("Redirection_url", svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/Error.jsp");
+ requestDispacher.forward(request, response);
+ return;
+ }
+ log.debug("Commit success");
+ request.setAttribute("Redirection_url", svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/Redirect.jsp");
+// Deleting temp directory
+
+ log.debug("Deleting temporary directory : " + svnSess.getCheckoutdir());
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+// End of Second part
+
+ requestDispacher.forward(request, response);
+ log.debug("Exit RSTEditor");
+
+ } catch (SVNException ex) {
+ Logger.getLogger(HelloServlet.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ protected static CodepageDetectorProxy detector;
+ private static final Log log = LogFactory.getLog(HelloServlet.class);
+
+ protected static CodepageDetectorProxy getCodepageDetector() {
+
+ if (detector == null) {
+ detector = CodepageDetectorProxy.getInstance(); // A singleton.
+
+ // Add the implementations of info.monitorenter.cpdetector.io.ICodepageDetector:
+ // This one is quick if we deal with unicode codepages:
+ detector.add(new ByteOrderMarkDetector());
+ // The first instance delegated to tries to detect the meta charset attribut in html pages.
+ detector.add(new ParsingDetector(true)); // be verbose about parsing.
+ // This one does the tricks of exclusion and frequency detection, if first implementation is
+ // unsuccessful:
+ detector.add(JChardetFacade.getInstance()); // Another singleton.
+ detector.add(ASCIIDetector.getInstance()); // Fallback, see javadoc.
+ }
+ return detector;
+ }
+
+
+ /**
+ * Convert all files to UTF-8.
+ *
+ * @param files fiels to convert
+ * @return converted file list
+ */
+ public static List<File> convertToUnicode(List<File> files) {
+
+ CodepageDetectorProxy myDetector = getCodepageDetector();
+
+ for (File file : files) {
+ try {
+ Charset charset = myDetector.detectCodepage(file.toURI().toURL());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Charset for " + file.getAbsolutePath() + " is " + charset);
+ }
+
+ if (charset != null && !charset.name().equalsIgnoreCase("UTF-8")) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Convert " + file.getAbsolutePath() + " to unicode");
+ }
+
+ File tmpFile = File.createTempFile(file.getName(), ".copy");
+ tmpFile.deleteOnExit();
+
+ // direct copy
+ InputStream is = new FileInputStream(file);
+ OutputStream os = new FileOutputStream(tmpFile);
+ try {
+ IOUtils.copy(is, os);
+ }
+ finally {
+ is.close();
+ os.close();
+ }
+
+ // copy using cp transaltion
+ is = new FileInputStream(tmpFile);
+ os = new FileOutputStream(file);
+ Reader ir = new InputStreamReader(is, charset);
+ Writer ow = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ try {
+ IOUtils.copy(ir, ow);
+ }
+ finally {
+ ir.close();
+ ow.close();
+ is.close();
+ os.close();
+ }
+
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("File " + file.getAbsolutePath() + " already in unicode : skip");
+ }
+ }
+ } catch (MalformedURLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ }
+
+ }
+
+ return files;
+ }
+}
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/PreviewServlet.java 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,177 @@
+package org.nuiton.jrst;
+
+import info.monitorenter.cpdetector.io.ASCIIDetector;
+import info.monitorenter.cpdetector.io.ByteOrderMarkDetector;
+import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
+import info.monitorenter.cpdetector.io.JChardetFacade;
+import info.monitorenter.cpdetector.io.ParsingDetector;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.List;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author geoffroy lorieux
+ */
+public class PreviewServlet extends HttpServlet {
+
+ /**
+ * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ log.debug("je suis dans la previewservlet");
+ HttpSession httpSession = request.getSession(true);
+ File tmp_dir = (File) getServletContext().getAttribute("javax.servlet.context.tempdir");
+ log.debug("Le tmp dir est :" + tmp_dir);
+ log.debug("Le content type est : " + request.getContentType());
+// Text recuperation
+ String myData = request.getParameter("text");
+
+ String myDataWithoutcrlf = myData.replace("\r", "");
+ File file_in_dir_copy = new File(tmp_dir, "copy"+httpSession.getId()+".rst");
+ File http_file = new File(tmp_dir, "preview"+httpSession.getId()+".html");
+ file_in_dir_copy.createNewFile();
+ http_file.createNewFile();
+ FileUtils.writeStringToFile(file_in_dir_copy, myDataWithoutcrlf);
+ List<File> list = new java.util.ArrayList<File>(1);
+ list.add(0, file_in_dir_copy);
+ list = convertToUnicode(list);
+ File copy = new File(tmp_dir, "copy"+httpSession.getId()+".rst");
+ try{
+ JRST.generate(JRST.TYPE_HTML, copy, http_file, JRST.Overwrite.ALLTIME);
+ log.debug("generate okai");
+ } catch (Exception eee) {
+ log.debug("Bad RST file");
+ response.setStatus(406);
+ return;
+ }
+ copy.delete();
+ response.setContentType("text/html");
+ PrintWriter ret = response.getWriter();
+ ret.print(FileUtils.readFileToString(http_file));
+ http_file.delete();
+ }
+
+ protected static CodepageDetectorProxy detector;
+ private static final Log log = LogFactory.getLog(PreviewServlet.class);
+
+ protected static CodepageDetectorProxy getCodepageDetector() {
+
+ if (detector == null) {
+ detector = CodepageDetectorProxy.getInstance(); // A singleton.
+
+ // Add the implementations of info.monitorenter.cpdetector.io.ICodepageDetector:
+ // This one is quick if we deal with unicode codepages:
+ detector.add(new ByteOrderMarkDetector());
+ // The first instance delegated to tries to detect the meta charset attribut in html pages.
+ detector.add(new ParsingDetector(true)); // be verbose about parsing.
+ // This one does the tricks of exclusion and frequency detection, if first implementation is
+ // unsuccessful:
+ detector.add(JChardetFacade.getInstance()); // Another singleton.
+ detector.add(ASCIIDetector.getInstance()); // Fallback, see javadoc.
+ }
+ return detector;
+ }
+
+
+ /**
+ * Convert all files to UTF-8.
+ *
+ * @param files fiels to convert
+ * @return converted file list
+ */
+ public static List<File> convertToUnicode(List<File> files) {
+
+ CodepageDetectorProxy myDetector = getCodepageDetector();
+
+ for (File file : files) {
+ try {
+ Charset charset = myDetector.detectCodepage(file.toURI().toURL());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Charset for " + file.getAbsolutePath() + " is " + charset);
+ }
+
+ if (charset != null && !charset.name().equalsIgnoreCase("UTF-8")) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Convert " + file.getAbsolutePath() + " to unicode");
+ }
+
+ File tmpFile = File.createTempFile(file.getName(), ".copy");
+ tmpFile.deleteOnExit();
+
+ // direct copy
+ InputStream is = new FileInputStream(file);
+ OutputStream os = new FileOutputStream(tmpFile);
+ try {
+ IOUtils.copy(is, os);
+ }
+ finally {
+ is.close();
+ os.close();
+ }
+
+ // copy using cp transaltion
+ is = new FileInputStream(tmpFile);
+ os = new FileOutputStream(file);
+ Reader ir = new InputStreamReader(is, charset);
+ Writer ow = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ try {
+ IOUtils.copy(ir, ow);
+ }
+ finally {
+ ir.close();
+ ow.close();
+ is.close();
+ os.close();
+ }
+
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("File " + file.getAbsolutePath() + " already in unicode : skip");
+ }
+ }
+ } catch (MalformedURLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ }
+
+ }
+
+ return files;
+ }
+}
+
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/PrivateSvnServlet.java 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,46 @@
+package org.nuiton.jrst;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+/**
+ * @author geoffroy lorieux
+ */
+public class PrivateSvnServlet extends HttpServlet{
+
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ log.debug("New Log setting");
+ HttpSession httpSession = request.getSession(true);
+ System.setProperty("file.encoding", "UTF-8");
+ PrintWriter out = response.getWriter();
+ SvnSession svnSess = (SvnSession) httpSession.getAttribute("myInfo");
+// Resetting User Information
+ svnSess.setLogin(request.getParameter("username"));
+ svnSess.setPassword(request.getParameter("pw"));
+ svnSess.setAuthManager(SVNWCUtil.createDefaultAuthenticationManager(svnSess.getCheckoutdir(),svnSess.getLogin(), svnSess.getPassword(), false));
+ svnSess.setManager(SVNClientManager.newInstance(svnSess.getSvnOption(), svnSess.getAuthManager()));
+ httpSession.setAttribute("myInfo", svnSess);
+ request.setAttribute("Redirect_url",
+ "http://localhost:8080/nuiton-rstedit/hello?adresse="+svnSess.getSvnPath()+"&"+"file_name="+svnSess.getFileName()+"&"+"projectUrl="+svnSess.getProjectUrl());
+ RequestDispatcher requestDispacher = this.getServletContext().getRequestDispatcher("/Recall.jsp");
+
+// End on first part
+ requestDispacher.forward(request, response);
+ out.close();
+ }
+ private static final Log log = LogFactory.getLog(PrivateSvnServlet.class);
+
+}
Added: nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java
===================================================================
--- nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java (rev 0)
+++ nuiton-rstedit/src/main/java/org/nuiton/jrst/SvnSession.java 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,129 @@
+package org.nuiton.jrst;
+
+import java.io.File;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNProperty;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
+import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+class SvnSession {
+
+ public ISVNAuthenticationManager getAuthManager() {
+ return authManager;
+ }
+
+ public void setAuthManager(ISVNAuthenticationManager authManager) {
+ this.authManager = authManager;
+ }
+
+ public File getCheckoutdir() {
+ return checkoutdir;
+ }
+
+ public void setCheckoutdir(File checkoutdir) {
+ this.checkoutdir = checkoutdir;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getLogin() {
+ return login;
+ }
+
+ public void setLogin(String login) {
+ this.login = login;
+ }
+
+ public SVNClientManager getManager() {
+ return manager;
+ }
+
+ public void setManager(SVNClientManager manager) {
+ this.manager = manager;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getProjectUrl() {
+ return projectUrl;
+ }
+
+ public void setProjectUrl(String projectUrl) {
+ this.projectUrl = projectUrl;
+ }
+
+ public SVNURL getRemoteUrl() {
+ return remoteUrl;
+ }
+
+ public void setRemoteUrl(SVNURL remoteUrl) {
+ this.remoteUrl = remoteUrl;
+ }
+
+ public DefaultSVNOptions getSvnOption() {
+ return svnOption;
+ }
+
+ public void setSvnOption(DefaultSVNOptions svnOption) {
+ this.svnOption = svnOption;
+ }
+
+ public String getSvnPath() {
+ return svnPath;
+ }
+
+ public void setSvnPath(String svnPath) {
+ this.svnPath = svnPath;
+ }
+
+ public File getTmpDir() {
+ return tmpDir;
+ }
+
+ public void setTmpDir(File tmpDir) {
+ this.tmpDir = tmpDir;
+ }
+
+ String svnPath;// svn path without fileName
+ String fileName;// fileName of modif file
+ String projectUrl;// Projectname
+ String login;// user's login
+ String password;// user's password
+ File tmpDir;// Temp directory path
+ File checkoutdir;// Temp directory for checkout
+ SVNURL remoteUrl;// url of svn path
+ ISVNAuthenticationManager authManager;// AuthenticationManager with login and password
+ DefaultSVNOptions svnOption;// svn default option
+ SVNClientManager manager;
+
+ SvnSession(String svnPath, String fileName, String projectUrl, String login, String password, File tmpDir, String id) throws SVNException {
+ super();
+ this.svnPath = svnPath;
+ this.fileName = fileName;
+ this.projectUrl = projectUrl;
+ this.login = login;
+ this.password = password;
+ this.tmpDir = tmpDir;
+ this.checkoutdir = new File(this.tmpDir, "temp_rst" + id);
+ this.remoteUrl = SVNURL.parseURIEncoded(svnPath);
+ this.authManager = SVNWCUtil.createDefaultAuthenticationManager(this.checkoutdir, this.login, this.password, false);
+ this.svnOption = SVNWCUtil.createDefaultOptions(this.checkoutdir, false);
+ this.svnOption.setPropertyValue(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_LF);
+ this.manager = SVNClientManager.newInstance(this.svnOption, this.authManager);
+ }
+}
Added: nuiton-rstedit/src/main/resources/log4j.properties
===================================================================
--- nuiton-rstedit/src/main/resources/log4j.properties (rev 0)
+++ nuiton-rstedit/src/main/resources/log4j.properties 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,30 @@
+# Global logging configuration
+log4j.rootLogger=DEBUG, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+# File output...
+#log4j.appender.fileout=org.apache.log4j.FileAppender
+#log4j.appender.fileout.File=jtimer.log
+#log4j.appender.fileout.Append=true
+#log4j.appender.fileout.Threshold=DEBUG
+#log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
+#log4j.appender.fileout.layout.ConversionPattern=%5p (%F:%L) %m%n
+
+# Rolling appender
+#log4j.appender.rolling=org.apache.log4j.RollingFileAppender
+#log4j.appender.rolling.File=jtimer.log
+#log4j.appender.rolling.MaxFileSize=100KB
+#log4j.appender.rolling.Append=true
+#log4j.appender.rolling.MaxBackupIndex=30
+#log4j.appender.rolling.Threshold=INFO
+#log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
+#log4j.appender.rolling.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+# package level
+#log4j.logger.org.chorem.jtimer=DEBUG
+#log4j.logger.org.chorem.jtimer.ws=DEBUG
+#log4j.logger.org.chorem.jtimer.ui.report=DEBUG
Added: nuiton-rstedit/src/main/webapp/Error.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Error.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Error.jsp 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,22 @@
+<%--
+ Document : Error
+ Created on : 15 sept. 2009, 12:22:29
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Error</title>
+ <meta http-equiv="Refresh" content="2;
+ url=http://localhost:8080/nuiton-rstedit/hello?adresse=<%=request.getAttribute("Svnpath_url")%>&file_name=<%=request.getAttribute("Filename_url")%>&project_url=<%=request.getAttribute("Redirection_url")%>">
+ </head>
+ <body>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>Bad Login or Password. Please Wait.</p>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/GereFormSize.js
===================================================================
--- nuiton-rstedit/src/main/webapp/GereFormSize.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/GereFormSize.js 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,44 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+function countLines(strtocount, cols)
+ {
+ var hard_lines = 1;
+ var last = 0;
+ while ( true )
+ {
+ last = strtocount.indexOf("\n", last+1);
+ hard_lines ++;
+ if ( last == -1 )
+ {
+ break;
+ }
+ }
+ var soft_lines = Math.round(strtocount.length / (cols-1));
+ var hard = eval("hard_lines " + unescape("%3e") + "soft_lines;");
+ if ( hard )
+ {
+ soft_lines = hard_lines;
+ }
+ return soft_lines;
+ }
+function cleanForm()
+ {
+ var the_form = document.forms[0];
+ for ( var x in the_form )
+ {
+ if ( ! the_form[x] )
+ {
+ continue;
+ }
+ if( typeof the_form[x].rows != "number" )
+ {
+ continue;
+ }
+ the_form[x].rows = countLines(the_form[x].value,the_form[x].cols) +1;
+ }
+ setTimeout("cleanForm();", 300);
+ }
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/GereSession.js
===================================================================
--- nuiton-rstedit/src/main/webapp/GereSession.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/GereSession.js 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,41 @@
+/**
+ * @author geoffroy lorieux
+ */
+
+function rappelSession(minutes)
+{
+ var msg='Your session expire on '+minutes+' minute';
+ if(minutes>1)
+ {
+ msg+='s';
+ }
+ msg+='.\nDo you want to reload this page ?';
+
+ if(confirm(msg))
+ {
+ location.reload();
+ }
+}
+
+/**
+ * affiche une alerte sur l'expiration de la session et redirige vers une autre page
+ */
+function expirationSession()
+{
+ alert('Your session has expired. Please login again.');
+ window.history.back(-1);
+}
+
+/**
+ * affiche des avertissements sur le délai d'expiration de la session :
+ * - un premier au bout de (expiration-rappel) minutes (par ex. : 20-3 = 17 minutes)
+ * - un second au bout de (expiration) minutes (par ex. : 20 minutes)
+ */
+function geresession(expiration, rappel)
+{
+ // affichage du rappel
+ var chronoRappel=setTimeout('rappelSession('+rappel+')', (expiration-rappel)*60*1000);
+
+ // une fois le rappel affiché, on avertit uniquement de l'expiration
+ var chronoExpiration=setTimeout('expirationSession()', expiration*60*1000);
+}
Added: nuiton-rstedit/src/main/webapp/ModificationViewer.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/ModificationViewer.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/ModificationViewer.jsp 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,42 @@
+<%--
+ Document : ModificationViewer
+ Created on : 10 sept. 2009, 13:43:11
+ Author : glorieux
+--%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>SCMWebEditor</title>
+
+ </head>
+<body onload="cleanForm(); geresession(<%=request.getAttribute("InvalidateMaxTime")%>, 5);">
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <center><h2><p>Welcome on SCMWebEditor</p></h2><h4><p>For any Problem with RestruturedText visit <a href="http://docutils.sourceforge.net/rst.html">RST documentation website</a>.</p></h4></center>
+ <center><form method="post" action="/nuiton-rstedit/hello">
+ <script src="GereFormSize.js"></script>
+ <textarea name="Mytext" id="Mytext" rows="20" cols="150"><%=request.getAttribute("OrigText")%></textarea>
+ <script src="Preview.js"></script>
+ <script src="Saver.js"></script>
+ <script src="GereSession.js"></script>
+ <script src="cancelRedirect.js"></script>
+ <p>Commit Message: <input type="text" name="Commit_message"/></p>
+ <p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12></label>
+ <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12></label>
+ </p>
+ <input type="hidden" name="Orig_text" value="<%=request.getAttribute("OrigText")%>"/>
+ <input type="submit" value="Save" name="Save"/>
+ <input type="button" value="Save and Continue Editing" name="SaveandC" onclick="javascript:saver(this.form.Mytext, this.form.username, this.form.pw, this.form.Commit_message, this.form.Orig_text);"/>
+ <input type="button" value="Preview" name="Preview" onclick="javascript:preview(this.form.Mytext);"/>
+ <input type="reset" value="Reset" name="Reset" />
+ <input type="button" value="Cancel" name="Cancel" onclick="cancelRedirect();"/>
+ </form></center>
+
+ <h4><p>Older Text Preview :</p></h4>
+ <pre><%=request.getAttribute("OrigText")%></pre>
+</body>
+</html>
Added: nuiton-rstedit/src/main/webapp/Preview.js
===================================================================
--- nuiton-rstedit/src/main/webapp/Preview.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/Preview.js 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,59 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+
+function createRequestObject()
+{
+ var req;
+ if(window.XMLHttpRequest)
+ {
+ //For Firefox, Safari, Opera
+ req = new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ //For IE 5+
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ else
+ {
+ //Error for an old browser
+ alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
+ }
+ return req;
+}
+
+//Make the XMLHttpRequest Object
+var http= createRequestObject();
+
+function sendRequest(method, url, text)
+{
+
+ http.open(method, url, true);
+ http.onreadystatechange = handleResponse;
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.send("text="+text.value);
+}
+
+function handleResponse()
+{
+ if(http.readyState == 4 && http.status != 406)
+ {
+ var response = http.responseText;
+ var wind = window.open("", "Preview", "scrollbars=yes,resizable=yes,status=yes");
+ wind.document.body.innerHTML = response;
+ }
+ else if (http.readyState == 4 && http.status == 406)
+ {
+ alert("Bad RestructuredText file format please correct it.");
+ }
+}
+
+function preview(my_text)
+{
+ sendRequest("POST", "http://localhost:8080/nuiton-rstedit/previewservlet", my_text);
+}
+
Added: nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,29 @@
+<%--
+ Document : PrivateSvnRedirect
+ Created on : 30 sept. 2009, 14:05:43
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Private Scm</title>
+ </head>
+ <body><form method="post" action="/nuiton-rstedit/privatesvnservlet">
+ <script src="cancelRedirect.js"></script>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>You try to access a Private SCM. Please login</p>
+ <p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12></label>
+ <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12></label></p>
+ <input type="submit" value="Submit" name="Save"/>
+ <input type="button" value="Cancel" name="Cancel" onclick="cancelRedirect();"/>
+ <input type="hidden" name="adresse" value="<%=request.getAttribute("adresse")%>"/>
+ <input type="hidden" name="file_name" value="<%=request.getAttribute("file_name")%>"/>
+ <input type="hidden" name="project_url" value="<%=request.getAttribute("project_url")%>"/>
+ </form>
+ </body>
+</html>
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/Recall.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Recall.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Recall.jsp 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,17 @@
+<%--
+ Document : Recall
+ Created on : 30 sept. 2009, 17:05:40
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Redirect...</title>
+ <meta http-equiv="Refresh" content="0; url=<%=request.getAttribute("Redirect_url")%>">
+ </head>
+</html>
Added: nuiton-rstedit/src/main/webapp/Redirect.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Redirect.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Redirect.jsp 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,23 @@
+<%--
+ Document : Redirect
+ Created on : 10 sept. 2009, 13:43:11
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Redirection...</title>
+ <meta http-equiv="Refresh" content="2; url=<%=request.getAttribute("Redirection_url")%>">
+ </head>
+ <body>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>Thank you using RSTEditor</p>
+ <p>You should be transferred automatically to the new page. If
+not please <a href="<%=request.getAttribute("Redirection_url")%>">click this link</a>.</p>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/Saver.js
===================================================================
--- nuiton-rstedit/src/main/webapp/Saver.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/Saver.js 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,64 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+function createRequestObject()
+{
+ var req;
+ if(window.XMLHttpRequest)
+ {
+ //For Firefox, Safari, Opera
+ req = new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ //For IE 5+
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ else
+ {
+ //Error for an old browser
+ alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
+ }
+ return req;
+}
+
+//Make the XMLHttpRequest Object
+var http= createRequestObject();
+
+function sendReq(method, url, text, login, pass, message)
+{
+ http.open(method, url, true);
+ http.onreadystatechange = handleResp;
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.send("Mytext="+text.value+"&username="+login.value+"&pw="+pass.value+"&Commit_message="+message.value);
+}
+
+function handleResp()
+{
+ if(http.readyState == 4 && http.status != 401)
+ {
+ alert("Save Ok. This page will be reloaded shortly.");
+ window.location.reload(true);
+ }
+ else if (http.readyState == 4 && http.status == 401)
+ {
+ alert("Bad login or password please recheck.");
+ }
+}
+
+function saver(my_text, login, pass, message, orig_text)
+{
+ if (my_text.value != orig_text.value)
+ {
+ if (confirm("Do you really want to save?"))
+ {
+ sendReq("POST", "http://localhost:8080/nuiton-rstedit/hello", my_text, login, pass, message);
+ }
+ }
+ else
+ {
+ alert("File don't need to be save.");
+ }
+}
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/WEB-INF/web.xml
===================================================================
--- nuiton-rstedit/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ nuiton-rstedit/src/main/webapp/WEB-INF/web.xml 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
+ <servlet>
+ <servlet-name>HelloServlet</servlet-name>
+ <servlet-class>org.nuiton.jrst.HelloServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>PreviewServlet</servlet-name>
+ <servlet-class>org.nuiton.jrst.PreviewServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>Saveservlet</servlet-name>
+ <servlet-class>Saveservlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>PrivateSvnServlet</servlet-name>
+ <servlet-class>org.nuiton.jrst.PrivateSvnServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>HelloServlet</servlet-name>
+ <url-pattern>/hello</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>PreviewServlet</servlet-name>
+ <url-pattern>/previewservlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Saveservlet</servlet-name>
+ <url-pattern>/saveservlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>PrivateSvnServlet</servlet-name>
+ <url-pattern>/privatesvnservlet</url-pattern>
+ </servlet-mapping>
+ </web-app>
Added: nuiton-rstedit/src/main/webapp/cancelRedirect.js
===================================================================
--- nuiton-rstedit/src/main/webapp/cancelRedirect.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/cancelRedirect.js 2009-10-02 10:19:20 UTC (rev 268)
@@ -0,0 +1,12 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+function cancelRedirect()
+ {
+ if (confirm("Exit SCMWebEditor ?")){
+ window.history.back(-1);
+ }
+ }
\ No newline at end of file
1
0
Author: glorieux
Date: 2009-10-02 12:16:22 +0200 (Fri, 02 Oct 2009)
New Revision: 267
Removed:
nuiton-rstedit/
Log:
1
0
r266 - / nuiton-rstedit nuiton-rstedit/src nuiton-rstedit/src/main nuiton-rstedit/src/main/java nuiton-rstedit/src/main/resources nuiton-rstedit/src/main/webapp nuiton-rstedit/src/main/webapp/WEB-INF nuiton-rstedit/src/test
by glorieux@users.nuiton.org 01 Oct '09
by glorieux@users.nuiton.org 01 Oct '09
01 Oct '09
Author: glorieux
Date: 2009-10-01 15:05:22 +0200 (Thu, 01 Oct 2009)
New Revision: 266
Added:
nuiton-rstedit/
nuiton-rstedit/LICENSE.txt
nuiton-rstedit/README.txt
nuiton-rstedit/changelog.txt
nuiton-rstedit/pom.xml
nuiton-rstedit/src/
nuiton-rstedit/src/main/
nuiton-rstedit/src/main/java/
nuiton-rstedit/src/main/java/HelloServlet.java
nuiton-rstedit/src/main/java/PreviewServlet.java
nuiton-rstedit/src/main/java/PrivateSvnServlet.java
nuiton-rstedit/src/main/resources/
nuiton-rstedit/src/main/resources/log4j.properties
nuiton-rstedit/src/main/webapp/
nuiton-rstedit/src/main/webapp/Error.jsp
nuiton-rstedit/src/main/webapp/GereFormSize.js
nuiton-rstedit/src/main/webapp/GereSession.js
nuiton-rstedit/src/main/webapp/ModificationViewer.jsp
nuiton-rstedit/src/main/webapp/Preview.js
nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp
nuiton-rstedit/src/main/webapp/Recall.jsp
nuiton-rstedit/src/main/webapp/Redirect.jsp
nuiton-rstedit/src/main/webapp/Saver.js
nuiton-rstedit/src/main/webapp/WEB-INF/
nuiton-rstedit/src/main/webapp/WEB-INF/web.xml
nuiton-rstedit/src/main/webapp/cancelRedirect.js
nuiton-rstedit/src/test/
nuiton-rstedit/src/test/java/
Log:
Added: nuiton-rstedit/LICENSE.txt
===================================================================
--- nuiton-rstedit/LICENSE.txt (rev 0)
+++ nuiton-rstedit/LICENSE.txt 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: nuiton-rstedit/README.txt
===================================================================
--- nuiton-rstedit/README.txt (rev 0)
+++ nuiton-rstedit/README.txt 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Added: nuiton-rstedit/pom.xml
===================================================================
--- nuiton-rstedit/pom.xml (rev 0)
+++ nuiton-rstedit/pom.xml 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,173 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom</artifactId>
+ <version>1.0.2</version>
+ </parent>
+
+ <artifactId>nuiton-rstedit</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.tmatesoft.svnkit</groupId>
+ <artifactId>svnkit</artifactId>
+ <version>1.2.3.5521</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.jrst</groupId>
+ <artifactId>jrst</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.cpdetector</groupId>
+ <artifactId>cpdetector</artifactId>
+ <version>1.0.7</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>codelutin-repository</id>
+ <name>CodeLutinRepository</name>
+ <url>http://lutinbuilder.labs.libre-entreprise.org/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ </repository>
+ </repositories>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Nuiton-rstedit</name>
+ <description>.
+ </description>
+ <inceptionYear>2009</inceptionYear>
+ <url>http://maven-site.nuiton.org/${project.artifactId}</url>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>war</packaging>
+
+ <properties>
+
+
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.jrst</groupId>
+ <artifactId>doxia-module-jrst</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ </build>
+
+ <!-- Source control management. -->
+ <scm>
+ <connection>scm:svn:http://svn.nuiton.org/svn/mavenpom/nuiton-rstedit/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/mavenpom/nuiton-rstedit/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/mavenpom/nuiton-rstedit/trunk</url>
+ </scm>
+
+ <profiles>
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+
+ <plugins>
+
+ <!-- launch in a release the assembly automaticly -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-assemblies</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <attach>false</attach>
+ <descriptorRefs>
+ <descriptorRef>deps</descriptorRef>
+ <descriptorRef>full</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
Added: nuiton-rstedit/src/main/java/HelloServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/HelloServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/HelloServlet.java 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,335 @@
+import info.monitorenter.cpdetector.io.ASCIIDetector;
+import info.monitorenter.cpdetector.io.ByteOrderMarkDetector;
+import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
+import info.monitorenter.cpdetector.io.JChardetFacade;
+import info.monitorenter.cpdetector.io.ParsingDetector;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.tmatesoft.svn.core.SVNAuthenticationException;
+import org.tmatesoft.svn.core.SVNDepth;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNProperty;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNCommitClient;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.wc.SVNUpdateClient;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+
+/**
+ * @author geoffroy lorieux
+ */
+public class HelloServlet extends HttpServlet {
+
+
+ // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ try {
+
+// First Part Svn checkout and JSP call
+ log.debug("-----------------------");
+ log.debug("Connection to RSTEditor");
+ log.debug("-----------------------");
+ HttpSession sess = request.getSession(true);
+
+ Info my_inf = (sess.getAttribute("my_info") == null?
+ new Info(request.getParameter("adresse"), request.getParameter("file_name"), request.getParameter("project_url"),
+ null, null, (File) getServletContext().getAttribute("javax.servlet.context.tempdir"),sess.getId()) :
+ (Info) sess.getAttribute("my_info"));
+ System.setProperty("file.encoding", "UTF-8");
+ PrintWriter out = response.getWriter();
+
+// UTF-8 Test
+ if (SVNProperty.isUTF8(my_inf.svn_optn.getNativeCharset()) == true)
+ {
+ log.debug("Je suis en utf8");
+ }
+ else
+ {
+ log.debug("Je ne suis pas en utf8");
+ }
+
+ sess.setAttribute("my_info", my_inf);
+// Tempdir creation
+
+ log.debug("Creating temporary directory on: " + my_inf.checkoutdir);
+ my_inf.checkoutdir.mkdir();
+
+// doCheckout declaration
+
+ DAVRepositoryFactory.setup();
+ SVNUpdateClient upclient = new SVNUpdateClient(my_inf.manager, my_inf.svn_optn);
+
+// Checkout svn and file organisation
+ try{
+ log.debug("Do Checkout");
+ upclient.doCheckout(my_inf.remote_url, my_inf.checkoutdir,
+ SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.FILES, false);
+ }
+ catch (SVNAuthenticationException authexep){
+ log.debug("Private SVN on reading");
+ FileUtils.deleteDirectory(my_inf.checkoutdir);
+ request.setAttribute("adresse", my_inf.svnpath);
+ request.setAttribute("file_name", my_inf.filename);
+ request.setAttribute("project_url", my_inf.project_url);
+ RequestDispatcher disp = this.getServletContext().getRequestDispatcher("/PrivateSvnRedirect.jsp");
+ disp.forward(request, response);
+ return;
+ }
+ log.debug("Checkout done");
+ File file_in_dir = new File(my_inf.checkoutdir, my_inf.filename);
+
+ String original_text = FileUtils.readFileToString(file_in_dir);
+
+// JSP data transfert
+ request.setAttribute("OrigText", original_text);
+ request.setAttribute("InvalidateMaxTime", (sess.getMaxInactiveInterval()/60));
+ log.debug("Invalidate time is :"+(sess.getMaxInactiveInterval()/60));
+ request.setAttribute("Reminder", ((sess.getMaxInactiveInterval()/10)/60));
+ log.debug("Reminder time is :"+((sess.getMaxInactiveInterval()/10)/60));
+ RequestDispatcher disp = this.getServletContext().getRequestDispatcher("/ModificationViewer.jsp");
+
+// End on first part
+ disp.forward(request, response);
+ out.close();
+ } catch (SVNException ex) {
+ Logger.getLogger(HelloServlet.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException{
+ try {
+
+// Second Part Client response and SVN commit
+ System.setProperty("file.encoding", "UTF-8");
+ HttpSession sess = request.getSession(true);
+ Info my_inf = (Info) sess.getAttribute("my_info");
+
+// Resetting authentification information and manager
+ my_inf.login = (Info) sess.getAttribute("my_info") != null ? my_inf.login : request.getParameter("username");
+ my_inf.password = (Info) sess.getAttribute("my_info") != null ? my_inf.password : request.getParameter("pw");
+ my_inf.auth_manager = SVNWCUtil.createDefaultAuthenticationManager(my_inf.checkoutdir,my_inf.login, my_inf.password, false);
+ my_inf.manager = SVNClientManager.newInstance(my_inf.svn_optn, my_inf.auth_manager);
+
+ File path_to_file = new File(my_inf.checkoutdir, my_inf.filename);
+
+ SVNCommitClient comcli = new SVNCommitClient(my_inf.manager, my_inf.svn_optn);
+ FileUtils.writeStringToFile(path_to_file, request.getParameter("Mytext"));
+
+ List<File> list = new java.util.ArrayList<File>(1);
+ list.add(0, path_to_file);
+
+ list = convertToUnicode(list);
+
+ File[] tab_file = new File[1];
+ tab_file[0] = path_to_file;
+// Sending Data to SVN
+ try
+ {
+ log.debug("Try to Commit");
+ comcli.doCommit(tab_file, false, request.getParameter("Commit_message"), null, null, false, true, SVNDepth.FILES);
+ }
+ catch (SVNAuthenticationException authexep)
+ {
+ log.debug("Bad Login or Password");
+ response.setStatus(401);
+ request.setAttribute("Svnpath_url", my_inf.svnpath);
+ request.setAttribute("Filename_url", my_inf.filename);
+ request.setAttribute("Redirection_url", my_inf.project_url);
+ RequestDispatcher disp = this.getServletContext().getRequestDispatcher("/Error.jsp");
+ disp.forward(request, response);
+ return;
+ }
+ log.debug("Commit success");
+ request.setAttribute("Redirection_url", my_inf.project_url);
+ RequestDispatcher disp = this.getServletContext().getRequestDispatcher("/Redirect.jsp");
+// Deleting temp directory
+
+ log.debug("Deleting temporary directory : " + my_inf.checkoutdir);
+ FileUtils.deleteDirectory(my_inf.checkoutdir);
+// End of Second part
+
+ disp.forward(request, response);
+ log.debug("Exit RSTEditor");
+
+ } catch (SVNException ex) {
+ Logger.getLogger(HelloServlet.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+// Information object
+
+ static protected class Info{
+
+ String svnpath; // svn path without filename
+ String filename; // filename of modif file
+ String project_url; // Projectname
+ String login; // user's login
+ String password; // user's password
+ File tmp_dir; // Temp directory path
+ File checkoutdir; // Temp directory for checkout
+ SVNURL remote_url; // url of svn path
+ ISVNAuthenticationManager auth_manager; // authmanager with login and password
+ DefaultSVNOptions svn_optn; // svn default option
+ SVNClientManager manager; // svn manager with default option and authentification manager
+
+
+ Info (String svnpath, String filename, String project_url, String login, String password, File tmp_dir,String id) throws SVNException{
+ this.svnpath = svnpath;
+ this.filename = filename;
+ this.project_url = project_url;
+ this.login = login;
+ this.password = password;
+ this.tmp_dir = tmp_dir;
+ this.checkoutdir = new File(this.tmp_dir, "temp_rst"+id);
+ this.remote_url = SVNURL.parseURIEncoded(svnpath);
+ this.auth_manager = SVNWCUtil.createDefaultAuthenticationManager(this.checkoutdir, this.login, this.password, false);
+ this.svn_optn = SVNWCUtil.createDefaultOptions(this.checkoutdir, false);
+ this.svn_optn.setPropertyValue(SVNProperty.EOL_STYLE, SVNProperty.EOL_STYLE_LF);
+ this.manager = SVNClientManager.newInstance(this.svn_optn, this.auth_manager);
+
+ }
+ }
+
+ protected static CodepageDetectorProxy detector;
+ private static final Log log = LogFactory.getLog(HelloServlet.class);
+
+ protected static CodepageDetectorProxy getCodepageDetector() {
+
+ if (detector == null) {
+ detector = CodepageDetectorProxy.getInstance(); // A singleton.
+
+ // Add the implementations of info.monitorenter.cpdetector.io.ICodepageDetector:
+ // This one is quick if we deal with unicode codepages:
+ detector.add(new ByteOrderMarkDetector());
+ // The first instance delegated to tries to detect the meta charset attribut in html pages.
+ detector.add(new ParsingDetector(true)); // be verbose about parsing.
+ // This one does the tricks of exclusion and frequency detection, if first implementation is
+ // unsuccessful:
+ detector.add(JChardetFacade.getInstance()); // Another singleton.
+ detector.add(ASCIIDetector.getInstance()); // Fallback, see javadoc.
+ }
+ return detector;
+ }
+
+
+ /**
+ * Convert all files to UTF-8.
+ *
+ * @param files fiels to convert
+ * @return converted file list
+ */
+ public static List<File> convertToUnicode(List<File> files) {
+
+ CodepageDetectorProxy myDetector = getCodepageDetector();
+
+ for (File file : files) {
+ try {
+ Charset charset = myDetector.detectCodepage(file.toURI().toURL());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Charset for " + file.getAbsolutePath() + " is " + charset);
+ }
+
+ if (charset != null && !charset.name().equalsIgnoreCase("UTF-8")) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Convert " + file.getAbsolutePath() + " to unicode");
+ }
+
+ File tmpFile = File.createTempFile(file.getName(), ".copy");
+ tmpFile.deleteOnExit();
+
+ // direct copy
+ InputStream is = new FileInputStream(file);
+ OutputStream os = new FileOutputStream(tmpFile);
+ try {
+ IOUtils.copy(is, os);
+ }
+ finally {
+ is.close();
+ os.close();
+ }
+
+ // copy using cp transaltion
+ is = new FileInputStream(tmpFile);
+ os = new FileOutputStream(file);
+ Reader ir = new InputStreamReader(is, charset);
+ Writer ow = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ try {
+ IOUtils.copy(ir, ow);
+ }
+ finally {
+ ir.close();
+ ow.close();
+ is.close();
+ os.close();
+ }
+
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("File " + file.getAbsolutePath() + " already in unicode : skip");
+ }
+ }
+ } catch (MalformedURLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ }
+
+ }
+
+ return files;
+ }
+}
Added: nuiton-rstedit/src/main/java/PreviewServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/PreviewServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/PreviewServlet.java 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,182 @@
+import info.monitorenter.cpdetector.io.ASCIIDetector;
+import info.monitorenter.cpdetector.io.ByteOrderMarkDetector;
+import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
+import info.monitorenter.cpdetector.io.JChardetFacade;
+import info.monitorenter.cpdetector.io.ParsingDetector;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.jrst.JRST;
+
+/**
+ *
+ * @author glorieux
+ */
+public class PreviewServlet extends HttpServlet {
+
+ /**
+ * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ log.debug("je suis dans la previewservlet");
+ HttpSession sess = request.getSession(true);
+ File tmp_dir = (File) getServletContext().getAttribute("javax.servlet.context.tempdir");
+ log.debug("Le tmp dir est :" + tmp_dir);
+ log.debug("Le content type est : " + request.getContentType());
+// Text recuperation
+ String myData = request.getParameter("text");
+
+ String myDataWithoutcrlf = myData.replace("\r", "");
+ File file_in_dir_copy = new File(tmp_dir, "copy"+sess.getId()+".rst");
+ File http_file = new File(tmp_dir, "preview"+sess.getId()+".html");
+ file_in_dir_copy.createNewFile();
+ http_file.createNewFile();
+ FileUtils.writeStringToFile(file_in_dir_copy, myDataWithoutcrlf);
+ List<File> list = new java.util.ArrayList<File>(1);
+ list.add(0, file_in_dir_copy);
+ list = convertToUnicode(list);
+ File copy = new File(tmp_dir, "copy"+sess.getId()+".rst");
+ try
+ {
+ JRST.generate(JRST.TYPE_HTML, copy, http_file, JRST.Overwrite.ALLTIME);
+ log.debug("generate okai");
+ }
+ catch (Exception eee)
+ {
+ log.debug("Bad RST file");
+ response.setStatus(406);
+ return;
+ }
+ copy.delete();
+ response.setContentType("text/html");
+ PrintWriter ret = response.getWriter();
+ ret.print(FileUtils.readFileToString(http_file));
+ http_file.delete();
+ }
+
+ protected static CodepageDetectorProxy detector;
+ private static final Log log = LogFactory.getLog(PreviewServlet.class);
+
+ protected static CodepageDetectorProxy getCodepageDetector() {
+
+ if (detector == null) {
+ detector = CodepageDetectorProxy.getInstance(); // A singleton.
+
+ // Add the implementations of info.monitorenter.cpdetector.io.ICodepageDetector:
+ // This one is quick if we deal with unicode codepages:
+ detector.add(new ByteOrderMarkDetector());
+ // The first instance delegated to tries to detect the meta charset attribut in html pages.
+ detector.add(new ParsingDetector(true)); // be verbose about parsing.
+ // This one does the tricks of exclusion and frequency detection, if first implementation is
+ // unsuccessful:
+ detector.add(JChardetFacade.getInstance()); // Another singleton.
+ detector.add(ASCIIDetector.getInstance()); // Fallback, see javadoc.
+ }
+ return detector;
+ }
+
+
+ /**
+ * Convert all files to UTF-8.
+ *
+ * @param files fiels to convert
+ * @return converted file list
+ */
+ public static List<File> convertToUnicode(List<File> files) {
+
+ CodepageDetectorProxy myDetector = getCodepageDetector();
+
+ for (File file : files) {
+ try {
+ Charset charset = myDetector.detectCodepage(file.toURI().toURL());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Charset for " + file.getAbsolutePath() + " is " + charset);
+ }
+
+ if (charset != null && !charset.name().equalsIgnoreCase("UTF-8")) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Convert " + file.getAbsolutePath() + " to unicode");
+ }
+
+ File tmpFile = File.createTempFile(file.getName(), ".copy");
+ tmpFile.deleteOnExit();
+
+ // direct copy
+ InputStream is = new FileInputStream(file);
+ OutputStream os = new FileOutputStream(tmpFile);
+ try {
+ IOUtils.copy(is, os);
+ }
+ finally {
+ is.close();
+ os.close();
+ }
+
+ // copy using cp transaltion
+ is = new FileInputStream(tmpFile);
+ os = new FileOutputStream(file);
+ Reader ir = new InputStreamReader(is, charset);
+ Writer ow = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ try {
+ IOUtils.copy(ir, ow);
+ }
+ finally {
+ ir.close();
+ ow.close();
+ is.close();
+ os.close();
+ }
+
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("File " + file.getAbsolutePath() + " already in unicode : skip");
+ }
+ }
+ } catch (MalformedURLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't convert file in unicode", e);
+ }
+ }
+
+ }
+
+ return files;
+ }
+}
+
Added: nuiton-rstedit/src/main/java/PrivateSvnServlet.java
===================================================================
--- nuiton-rstedit/src/main/java/PrivateSvnServlet.java (rev 0)
+++ nuiton-rstedit/src/main/java/PrivateSvnServlet.java 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,51 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+/**
+ *
+ * @author glorieux
+ */
+public class PrivateSvnServlet extends HttpServlet{
+
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ log.debug("New Log setting");
+ HttpSession sess = request.getSession(true);
+ System.setProperty("file.encoding", "UTF-8");
+ PrintWriter out = response.getWriter();
+ HelloServlet.Info my_inf = (HelloServlet.Info) sess.getAttribute("my_info");
+// Resetting User Information
+ my_inf.login = request.getParameter("username");
+ my_inf.password = request.getParameter("pw");
+ my_inf.auth_manager = SVNWCUtil.createDefaultAuthenticationManager(my_inf.checkoutdir,my_inf.login, my_inf.password, false);
+ my_inf.manager = SVNClientManager.newInstance(my_inf.svn_optn, my_inf.auth_manager);
+ sess.setAttribute("my_info", my_inf);
+ request.setAttribute("Redirect_url",
+ "http://localhost:8080/nuiton-rstedit/hello?adresse="+my_inf.svnpath+"&"+"file_name="+my_inf.filename+"&"+"project_url="+my_inf.project_url);
+ RequestDispatcher disp = this.getServletContext().getRequestDispatcher("/Recall.jsp");
+
+// End on first part
+ disp.forward(request, response);
+ out.close();
+ }
+ private static final Log log = LogFactory.getLog(PrivateSvnServlet.class);
+
+}
Added: nuiton-rstedit/src/main/resources/log4j.properties
===================================================================
--- nuiton-rstedit/src/main/resources/log4j.properties (rev 0)
+++ nuiton-rstedit/src/main/resources/log4j.properties 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,30 @@
+# Global logging configuration
+log4j.rootLogger=DEBUG, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+# File output...
+#log4j.appender.fileout=org.apache.log4j.FileAppender
+#log4j.appender.fileout.File=jtimer.log
+#log4j.appender.fileout.Append=true
+#log4j.appender.fileout.Threshold=DEBUG
+#log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
+#log4j.appender.fileout.layout.ConversionPattern=%5p (%F:%L) %m%n
+
+# Rolling appender
+#log4j.appender.rolling=org.apache.log4j.RollingFileAppender
+#log4j.appender.rolling.File=jtimer.log
+#log4j.appender.rolling.MaxFileSize=100KB
+#log4j.appender.rolling.Append=true
+#log4j.appender.rolling.MaxBackupIndex=30
+#log4j.appender.rolling.Threshold=INFO
+#log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
+#log4j.appender.rolling.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+# package level
+#log4j.logger.org.chorem.jtimer=DEBUG
+#log4j.logger.org.chorem.jtimer.ws=DEBUG
+#log4j.logger.org.chorem.jtimer.ui.report=DEBUG
Added: nuiton-rstedit/src/main/webapp/Error.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Error.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Error.jsp 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,22 @@
+<%--
+ Document : Error
+ Created on : 15 sept. 2009, 12:22:29
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Error</title>
+ <meta http-equiv="Refresh" content="2;
+ url=http://localhost:8080/nuiton-rstedit/hello?adresse=<%=request.getAttribute("Svnpath_url")%>&file_name=<%=request.getAttribute("Filename_url")%>&project_url=<%=request.getAttribute("Redirection_url")%>">
+ </head>
+ <body>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>Bad Login or Password. Please Wait.</p>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/GereFormSize.js
===================================================================
--- nuiton-rstedit/src/main/webapp/GereFormSize.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/GereFormSize.js 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,44 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+function countLines(strtocount, cols)
+ {
+ var hard_lines = 1;
+ var last = 0;
+ while ( true )
+ {
+ last = strtocount.indexOf("\n", last+1);
+ hard_lines ++;
+ if ( last == -1 )
+ {
+ break;
+ }
+ }
+ var soft_lines = Math.round(strtocount.length / (cols-1));
+ var hard = eval("hard_lines " + unescape("%3e") + "soft_lines;");
+ if ( hard )
+ {
+ soft_lines = hard_lines;
+ }
+ return soft_lines;
+ }
+function cleanForm()
+ {
+ var the_form = document.forms[0];
+ for ( var x in the_form )
+ {
+ if ( ! the_form[x] )
+ {
+ continue;
+ }
+ if( typeof the_form[x].rows != "number" )
+ {
+ continue;
+ }
+ the_form[x].rows = countLines(the_form[x].value,the_form[x].cols) +1;
+ }
+ setTimeout("cleanForm();", 300);
+ }
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/GereSession.js
===================================================================
--- nuiton-rstedit/src/main/webapp/GereSession.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/GereSession.js 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,42 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+function rappelSession(minutes)
+{
+ var msg='your session expire on '+minutes+' minute';
+ if(minutes>1)
+ {
+ msg+='s';
+ }
+ msg+='.\nDo you want to reload this page ?';
+
+ if(confirm(msg))
+ {
+ location.reload();
+ }
+}
+
+/**
+ * affiche une alerte sur l'expiration de la session et redirige vers une autre page
+ */
+function expirationSession()
+{
+ alert('Your session has expired. Please login again.');
+ window.history.back(-1);
+}
+
+/**
+ * affiche des avertissements sur le délai d'expiration de la session :
+ * - un premier au bout de (expiration-rappel) minutes (par ex. : 20-3 = 17 minutes)
+ * - un second au bout de (expiration) minutes (par ex. : 20 minutes)
+ */
+function geresession(expiration, rappel)
+{
+ // affichage du rappel
+ var chronoRappel=setTimeout('rappelSession('+rappel+')', (expiration-rappel)*60*1000);
+
+ // une fois le rappel affiché, on avertit uniquement de l'expiration
+ var chronoExpiration=setTimeout('expirationSession()', expiration*60*1000);
+}
Added: nuiton-rstedit/src/main/webapp/ModificationViewer.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/ModificationViewer.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/ModificationViewer.jsp 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,42 @@
+<%--
+ Document : ModificationViewer
+ Created on : 10 sept. 2009, 13:43:11
+ Author : glorieux
+--%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>SCMWebEditor</title>
+
+ </head>
+<body onload="cleanForm(); geresession(<%=request.getAttribute("InvalidateMaxTime")%>, <%=request.getAttribute("Reminder")%>);">
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <center><h2><p>Welcome on SCMWebEditor</p></h2><h4><p>For any Problem with RestruturedText visit <a href="http://docutils.sourceforge.net/rst.html">RST documentation website</a>.</p></h4></center>
+ <center><form method="post" action="/nuiton-rstedit/hello">
+ <script src="GereFormSize.js"></script>
+ <textarea name="Mytext" id="Mytext" rows="20" cols="150"><%=request.getAttribute("OrigText")%></textarea>
+ <script src="Preview.js"></script>
+ <script src="Saver.js"></script>
+ <script src="GereSession.js"></script>
+ <script src="cancelRedirect.js"></script>
+ <p>Commit Message: <input type="text" name="Commit_message"/></p>
+
+ <p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12></label>
+ <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12></label></p>
+ <input type="hidden" name="Orig_text" value="<%=request.getAttribute("OrigText")%>"/>
+ <input type="submit" value="Save" name="Save"/>
+ <input type="button" value="Save and Continue Editing" name="SaveandC" onclick="javascript:saver(this.form.Mytext, this.form.username, this.form.pw, this.form.Commit_message, this.form.Orig_text);"/>
+ <input type="button" value="Preview" name="Preview" onclick="javascript:preview(this.form.Mytext);"/>
+ <input type="reset" value="Reset" name="Reset" />
+ <input type="button" value="Cancel" name="Cancel" onclick="cancelRedirect();"/>
+ </form></center>
+
+ <h4><p>Older Text Preview :</p></h4>
+ <pre><%=request.getAttribute("OrigText")%></pre>
+</body>
+</html>
Added: nuiton-rstedit/src/main/webapp/Preview.js
===================================================================
--- nuiton-rstedit/src/main/webapp/Preview.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/Preview.js 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,59 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+
+function createRequestObject()
+{
+ var req;
+ if(window.XMLHttpRequest)
+ {
+ //For Firefox, Safari, Opera
+ req = new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ //For IE 5+
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ else
+ {
+ //Error for an old browser
+ alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
+ }
+ return req;
+}
+
+//Make the XMLHttpRequest Object
+var http= createRequestObject();
+
+function sendRequest(method, url, text)
+{
+
+ http.open(method, url, true);
+ http.onreadystatechange = handleResponse;
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.send("text="+text.value);
+}
+
+function handleResponse()
+{
+ if(http.readyState == 4 && http.status != 406)
+ {
+ var response = http.responseText;
+ var wind = window.open("", "Preview", "scrollbars=yes,resizable=yes,status=yes");
+ wind.document.body.innerHTML = response;
+ }
+ else if (http.readyState == 4 && http.status == 406)
+ {
+ alert("Bad RestructuredText file format please correct it.");
+ }
+}
+
+function preview(my_text)
+{
+ sendRequest("POST", "http://localhost:8080/nuiton-rstedit/previewservlet", my_text);
+}
+
Added: nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/PrivateSvnRedirect.jsp 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,35 @@
+<%--
+ Document : PrivateSvnRedirect
+ Created on : 30 sept. 2009, 14:05:43
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Private Scm</title>
+ </head>
+ <body><form method="post" action="/nuiton-rstedit/privatesvnservlet">
+ <script language="javascript" type="text/javascript">
+ function cancelRedirect(){
+ if (confirm("Go Back ?")){
+ window.history.back(-1);
+ }
+ }
+ </script>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>You try to access a Private SCM. Please login</p>
+ <p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12></label>
+ <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12></label></p>
+ <input type="submit" value="Submit" name="Save"/>
+ <input type="button" value="Cancel" name="Cancel" onclick="cancelRedirect();"/>
+ <input type="hidden" name="adresse" value="<%=request.getAttribute("adresse")%>"/>
+ <input type="hidden" name="file_name" value="<%=request.getAttribute("file_name")%>"/>
+ <input type="hidden" name="project_url" value="<%=request.getAttribute("project_url")%>"/>
+ </form>
+ </body>
+</html>
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/Recall.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Recall.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Recall.jsp 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,17 @@
+<%--
+ Document : Recall
+ Created on : 30 sept. 2009, 17:05:40
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Redirect...</title>
+ <meta http-equiv="Refresh" content="0; url=<%=request.getAttribute("Redirect_url")%>">
+ </head>
+</html>
Added: nuiton-rstedit/src/main/webapp/Redirect.jsp
===================================================================
--- nuiton-rstedit/src/main/webapp/Redirect.jsp (rev 0)
+++ nuiton-rstedit/src/main/webapp/Redirect.jsp 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,23 @@
+<%--
+ Document : Redirect
+ Created on : 10 sept. 2009, 13:43:11
+ Author : glorieux
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Redirection...</title>
+ <meta http-equiv="Refresh" content="2; url=<%=request.getAttribute("Redirection_url")%>">
+ </head>
+ <body>
+ <img src="http://www.codelutin.com/images/lutinorange-codelutin.png" alt="$alt" />
+ <p>Thank you using RSTEditor</p>
+ <p>You should be transferred automatically to the new page. If
+not please <a href="<%=request.getAttribute("Redirection_url")%>">click this link</a>.</p>
+ </body>
+</html>
Added: nuiton-rstedit/src/main/webapp/Saver.js
===================================================================
--- nuiton-rstedit/src/main/webapp/Saver.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/Saver.js 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,64 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+function createRequestObject()
+{
+ var req;
+ if(window.XMLHttpRequest)
+ {
+ //For Firefox, Safari, Opera
+ req = new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ //For IE 5+
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ else
+ {
+ //Error for an old browser
+ alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
+ }
+ return req;
+}
+
+//Make the XMLHttpRequest Object
+var http= createRequestObject();
+
+function sendReq(method, url, text, login, pass, message)
+{
+ http.open(method, url, true);
+ http.onreadystatechange = handleResp;
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.send("Mytext="+text.value+"&username="+login.value+"&pw="+pass.value+"&Commit_message="+message.value);
+}
+
+function handleResp()
+{
+ if(http.readyState == 4 && http.status != 401)
+ {
+ alert("Save Ok. This page will be reloaded shortly.");
+ window.location.reload(true);
+ }
+ else if (http.readyState == 4 && http.status == 401)
+ {
+ alert("Bad login or password please recheck.");
+ }
+}
+
+function saver(my_text, login, pass, message, orig_text)
+{
+ if (my_text.value != orig_text.value)
+ {
+ if (confirm("Do you really want to save?"))
+ {
+ sendReq("POST", "http://localhost:8080/nuiton-rstedit/hello", my_text, login, pass, message);
+ }
+ }
+ else
+ {
+ alert("File don't need to be save.");
+ }
+}
\ No newline at end of file
Added: nuiton-rstedit/src/main/webapp/WEB-INF/web.xml
===================================================================
--- nuiton-rstedit/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ nuiton-rstedit/src/main/webapp/WEB-INF/web.xml 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
+ <servlet>
+ <servlet-name>HelloServlet</servlet-name>
+ <servlet-class>HelloServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>PreviewServlet</servlet-name>
+ <servlet-class>PreviewServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>Saveservlet</servlet-name>
+ <servlet-class>Saveservlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>PrivateSvnServlet</servlet-name>
+ <servlet-class>PrivateSvnServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>HelloServlet</servlet-name>
+ <url-pattern>/hello</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>PreviewServlet</servlet-name>
+ <url-pattern>/previewservlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Saveservlet</servlet-name>
+ <url-pattern>/saveservlet</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>PrivateSvnServlet</servlet-name>
+ <url-pattern>/privatesvnservlet</url-pattern>
+ </servlet-mapping>
+ </web-app>
Added: nuiton-rstedit/src/main/webapp/cancelRedirect.js
===================================================================
--- nuiton-rstedit/src/main/webapp/cancelRedirect.js (rev 0)
+++ nuiton-rstedit/src/main/webapp/cancelRedirect.js 2009-10-01 13:05:22 UTC (rev 266)
@@ -0,0 +1,13 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+function cancelRedirect()
+ {
+ if (confirm("Exit SCMWebEditor ?"))
+ {
+ window.history.back(-1);
+ }
+ }
\ No newline at end of file
1
0
Author: glorieux
Date: 2009-10-01 15:04:35 +0200 (Thu, 01 Oct 2009)
New Revision: 265
Removed:
nuiton-rstedit/
Log:
1
0