Scmwebeditor-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
- 436 discussions
r136 - in trunk: . src/main/java/org/nuiton/scmwebeditor src/main/java/org/nuiton/scmwebeditor/actions src/main/webapp
by kcardineaud@users.nuiton.org 24 Jun '11
by kcardineaud@users.nuiton.org 24 Jun '11
24 Jun '11
Author: kcardineaud
Date: 2011-06-24 15:43:55 +0200 (Fri, 24 Jun 2011)
New Revision: 136
Url: http://nuiton.org/repositories/revision/scmwebeditor/136
Log:
Svn files are show in order by repertory
Added:
trunk/src/main/java/org/nuiton/scmwebeditor/UrlSvnFile.java
Modified:
trunk/pom.xml
trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java
trunk/src/main/webapp/BadFileRedirect.jsp
trunk/src/main/webapp/Search.jsp
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-06-24 08:13:58 UTC (rev 135)
+++ trunk/pom.xml 2011-06-24 13:43:55 UTC (rev 136)
@@ -73,6 +73,11 @@
<version>1.2.1</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.tika</groupId>
+ <artifactId>tika-core</artifactId>
+ <version>0.9</version>
+ </dependency>
<!-- Struts -->
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java 2011-06-24 08:13:58 UTC (rev 135)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java 2011-06-24 13:43:55 UTC (rev 136)
@@ -30,6 +30,11 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.AutoDetectParser;
+import org.apache.tika.sax.BodyContentHandler;
+import org.xml.sax.SAXException;
import com.opensymphony.xwork2.ActionSupport;
@@ -78,7 +83,7 @@
protected static final String ATTRIBUTE_LOGIN = "Login";
protected static final String ATTRIBUTE_IS_LOGIN = "IsLogin";
protected static final String ATTRIBUTE_BAD_LOGIN = "badLogin";
- protected static final String ATTRIBUTE_PROJECT_URL = "Project_url";
+ protected static final String ATTRIBUTE_PROJECT_URL = "projectUrl";
protected static final String ATTRIBUTE_SCM_EDITOR_URI = "scmEditorUri";
protected static final String ATTRIBUTE_PREVIEW_SERVLET_URL = "previewServletUrl";
protected static final String ATTRIBUTE_FILESEARCH_SERVLET_URL = "searchServletUrl";
@@ -215,5 +220,18 @@
String url = buffer.toString();
return url;
}
+
+
+ protected String getMineType(File file) throws IOException, SAXException, TikaException {
+ FileInputStream is = new FileInputStream(file);
+ BodyContentHandler contenthandler = new BodyContentHandler();
+ Metadata metadata = new Metadata();
+ metadata.set(Metadata.RESOURCE_NAME_KEY, file.getName());
+ AutoDetectParser parser = new AutoDetectParser();
+ parser.parse(is, contenthandler, metadata);
+ String result = metadata.get(Metadata.CONTENT_TYPE);
+ log.info("Mine type of " + file.getName() + " is : " + result);
+ return result;
+ }
}
Added: trunk/src/main/java/org/nuiton/scmwebeditor/UrlSvnFile.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/UrlSvnFile.java (rev 0)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/UrlSvnFile.java 2011-06-24 13:43:55 UTC (rev 136)
@@ -0,0 +1,50 @@
+package org.nuiton.scmwebeditor;
+
+
+
+public class UrlSvnFile implements java.lang.Comparable<UrlSvnFile> {
+ String url;
+
+ public UrlSvnFile (String url) {
+ this.url=url;
+ }
+
+ public String toString() {
+ return url;
+ }
+
+ public int getLevel() {
+ String[] tab = url.split("/");
+ return tab.length;
+ }
+
+
+ @Override
+ public int compareTo(UrlSvnFile o) {
+ int level1 = o.getLevel();
+ int level2 = this.getLevel();
+
+ if (level1 > level2) {
+ return -1;
+ }
+ else if(level1 == level2) {
+ if(o.toString().length() > this.toString().length()) {
+ return -1;
+ }
+ else if(o.toString().length() == this.toString().length()) {
+ return 0;
+ }
+ else {
+ return 1;
+ }
+
+ }
+ else {
+ return 1;
+ }
+ }
+
+
+
+
+}
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-24 08:13:58 UTC (rev 135)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-24 13:43:55 UTC (rev 136)
@@ -177,10 +177,6 @@
/*
* Commit process
*/
-
- String originalText = StringEscapeUtils.unescapeHtml(origText);
- String myText = StringEscapeUtils.unescapeHtml(newText);
-
File pathToFile = new File(svnSess.getCheckoutdir(), svnSess.getFileName());
SVNCommitClient commitClient = new SVNCommitClient(svnSess.getManager(), svnSess.getSvnOption());
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-24 08:13:58 UTC (rev 135)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-24 13:43:55 UTC (rev 136)
@@ -25,9 +25,7 @@
public class ScmWebEditorMainAction extends ScmWebEditorBaseAction implements ServletRequestAware {
- /**
- *
- */
+
private static final long serialVersionUID = 8361035067228171624L;
private static final Log log = LogFactory.getLog(ScmWebEditorMainAction.class);
@@ -110,6 +108,7 @@
log.debug("--------------------------");
log.debug("Connection to SCMWebEditor");
log.debug("--------------------------");
+
/* Si il n'y a pas de parametre, l'utilisateur est renvoyé
* vers la page de configuration (OutConnection)
@@ -158,7 +157,6 @@
setSvnSession(httpSession, svnSess);
-// Tempdir creation on servlet default temporary directory
DAVRepositoryFactory.setup();
@@ -186,6 +184,7 @@
return Action.LOGIN;
} catch (SVNException e) {
+ request.setAttribute("projectUrl", projectUrl);
//Suppression du repertoire temporaire
delTempDirectory(svnSess);
return "erreurPath";
@@ -193,7 +192,26 @@
File CheckOutFile = new File(svnSess.getCheckoutdir(), svnSess.getFileName());
+
+ String mineType =null;
try {
+ mineType = getMineType(CheckOutFile);
+ } catch (Exception e) {
+ if(log.isErrorEnabled()) {
+ log.error("",e);
+ }
+ }
+
+
+
+ // Si le fichier n'est pas de type texte, on ne peut pas l'éditer
+ if(!mineType.contains("text")) {
+ request.setAttribute("projectUrl", projectUrl);
+ return "erreurPath";
+ }
+
+
+ try {
String originalText = FileUtils.readFileToString(CheckOutFile);
request.setAttribute(PARAMETER_FORMAT, svnSess.getFormat());
request.setAttribute(ATTRIBUTE_ORIG_TEXT, StringEscapeUtils.escapeHtml(originalText));
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java 2011-06-24 08:13:58 UTC (rev 135)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java 2011-06-24 13:43:55 UTC (rev 136)
@@ -1,12 +1,14 @@
package org.nuiton.scmwebeditor.actions;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.scmwebeditor.ScmWebEditorBaseAction;
+import org.nuiton.scmwebeditor.UrlSvnFile;
import org.tmatesoft.svn.core.SVNAuthenticationException;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
@@ -36,7 +38,7 @@
String address;
- LinkedList<String> files;
+ LinkedList<UrlSvnFile> files;
String username;
String pw;
@@ -56,7 +58,7 @@
}
- public LinkedList<String> getFiles() {
+ public LinkedList<UrlSvnFile> getFiles() {
return files;
}
@@ -110,7 +112,7 @@
password=pw;
}
- files = new LinkedList<String>();
+ files = new LinkedList<UrlSvnFile>();
if(address.endsWith("/")) {
@@ -143,7 +145,7 @@
}
listEntries( repository , "" );
-
+ Collections.sort(files);
} catch (SVNAuthenticationException authexep) {
return "authError";
@@ -151,7 +153,8 @@
catch ( SVNException svne ) {
log.error("Can't access to the repository",svne);
}
-
+
+
return Action.SUCCESS;
}
@@ -161,8 +164,7 @@
try {
entries = repository.getDir( path, -1 , null , (Collection<?>) null );
} catch (SVNException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.error("Can not reach the repository",e);
}
Iterator<?> iterator = entries.iterator();
@@ -170,7 +172,6 @@
SVNDirEntry entry = (SVNDirEntry) iterator.next();
if(log.isInfoEnabled()) {
log.info("/" + (path.equals("") ? "" : path + "/") + entry.getName()+ "\n");
- info+="/" + (path.equals("") ? "" : path + "/") + entry.getName()+ "\n";
}
String fichier = address+"/" + (path.equals("") ? "" : path + "/") + entry.getName();
@@ -179,10 +180,13 @@
listEntries(repository, (path.equals("")) ? entry.getName() : path + "/" + entry.getName());
}
else {
+
// On ajoute dans la liste files seulement les fichiers et pas les répertoires
- files.add(fichier);
+ files.add(new UrlSvnFile(fichier));
+
}
}
+
}
@@ -202,6 +206,9 @@
return string;
}
}
+
-
+
+
+
}
Modified: trunk/src/main/webapp/BadFileRedirect.jsp
===================================================================
--- trunk/src/main/webapp/BadFileRedirect.jsp 2011-06-24 08:13:58 UTC (rev 135)
+++ trunk/src/main/webapp/BadFileRedirect.jsp 2011-06-24 13:43:55 UTC (rev 136)
@@ -10,14 +10,13 @@
<title>Error...</title>
<link rel="icon" href="img/ScmWebEditor_little.png" type="image/png">
<link rel="stylesheet" type="text/css" href="css/main.css">
-<meta http-equiv="Refresh" content="3; url=
-<%=request.getParameter("projectUrl")%>">
+<meta http-equiv="Refresh" content="3; url=<%=request.getAttribute("projectUrl")%>">
</head>
<body>
<a target="_blank" href="http://maven-site.nuiton.org/scmwebeditor/"><img src="img/ScmWebEditor_main.png" alt="$alt" /></a>
<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="<%=request.getParameter("projectUrl")%>">click
+please <a href="<%=request.getAttribute("projectUrl")%>">click
this link</a>.</p>
<p>©2004-2009 CodeLutin</p>
</body>
Modified: trunk/src/main/webapp/Search.jsp
===================================================================
--- trunk/src/main/webapp/Search.jsp 2011-06-24 08:13:58 UTC (rev 135)
+++ trunk/src/main/webapp/Search.jsp 2011-06-24 13:43:55 UTC (rev 136)
@@ -3,6 +3,7 @@
<%@page import="org.nuiton.scmwebeditor.actions.SearchAction"%>
<%@page import="java.util.LinkedList" %>
<%@page import="java.util.Iterator" %>
+<%@page import="org.nuiton.scmwebeditor.UrlSvnFile" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<sj:head jquerytheme="default"/>
@@ -13,15 +14,16 @@
<%
SearchAction action = SearchAction.getAction();
- LinkedList<String> files = action.getFiles();
+ LinkedList<UrlSvnFile> files = action.getFiles();
- Iterator<String> it = files.iterator();
+ Iterator<UrlSvnFile> it = files.iterator();
while(it.hasNext()) {
- String file = it.next();
+ UrlSvnFile file = it.next();
+
%>
<tr><td>
- <a href="checkout.action?address=<%=file%>&projectUrl="<%=request.getRequestURL()%>" ><%=file%></a>
+ <a href="checkout.action?address=<%=file%>" ><%=file+" "+file.getLevel()%></a>
</td></tr>
<% } %>
1
0
r135 - in trunk: . src/main/java/org/nuiton/scmwebeditor/actions
by kcardineaud@users.nuiton.org 24 Jun '11
by kcardineaud@users.nuiton.org 24 Jun '11
24 Jun '11
Author: kcardineaud
Date: 2011-06-24 10:13:58 +0200 (Fri, 24 Jun 2011)
New Revision: 135
Url: http://nuiton.org/repositories/revision/scmwebeditor/135
Log:
ScmWebEditor use the method String generate(String xslListOrOutType, String in) for parsing rst
Modified:
trunk/pom.xml
trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-06-24 08:07:02 UTC (rev 134)
+++ trunk/pom.xml 2011-06-24 08:13:58 UTC (rev 135)
@@ -50,7 +50,7 @@
<dependency>
<groupId>org.nuiton.jrst</groupId>
<artifactId>jrst</artifactId>
- <version>${jrstPluginVersion}</version>
+ <version>1.4-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
@@ -199,7 +199,7 @@
<dependency>
<groupId>org.nuiton.jrst</groupId>
<artifactId>doxia-module-jrst</artifactId>
- <version>${jrstPluginVersion}</version>
+ <version>1.4-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java 2011-06-24 08:07:02 UTC (rev 134)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java 2011-06-24 08:13:58 UTC (rev 135)
@@ -1,14 +1,8 @@
package org.nuiton.scmwebeditor.actions;
-import java.io.File;
-import java.io.IOException;
-
-
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ServletRequestAware;
@@ -62,31 +56,11 @@
log.debug("Enter in preview action");
}
- HttpSession httpSession = request.getSession(true);
- File tmpDir = getTempDir(httpSession);
- //Text recuperation
- String myData = newText;
- //Text formating and tempfile creating
- String myDataWithoutcrlf = myData.replace("\r", "");
- File fileInDirCopy = new File(tmpDir, "copy" + httpSession.getId() + ".rst");
- File httpFile = new File(tmpDir, "preview" + httpSession.getId() + ".html");
- try {
- fileInDirCopy.createNewFile();
- httpFile.createNewFile();
- FileUtils.writeStringToFile(fileInDirCopy, myDataWithoutcrlf);
- } catch (IOException e) {
- if(log.isErrorEnabled()) {
- log.error("read/write error",e);
- }
- }
-
- convertToUnicode(fileInDirCopy);
- File copy = new File(tmpDir, "copy" + httpSession.getId() + ".rst");
//Using jrst for generate html document
try {
- JRST.generate(JRST.TYPE_HTML, copy, httpFile, JRST.Overwrite.ALLTIME);
+ XMLResponse = JRST.generate(JRST.TYPE_HTML, newText);
if(log.isDebugEnabled()) {
log.debug("RST generate");
}
@@ -97,19 +71,10 @@
XMLResponse = "<h4>Parsing error, please read RST specification<h4>";
return;
}
- copy.delete();
+
-
- try {
- XMLResponse = FileUtils.readFileToString(httpFile);
- } catch (IOException e) {
- e.printStackTrace();
- }
- httpFile.delete();
-
-
}
static public PreviewAction getAction() {
1
0
r134 - in trunk/src/main: java/org/nuiton/scmwebeditor java/org/nuiton/scmwebeditor/actions webapp
by kcardineaud@users.nuiton.org 24 Jun '11
by kcardineaud@users.nuiton.org 24 Jun '11
24 Jun '11
Author: kcardineaud
Date: 2011-06-24 10:07:02 +0200 (Fri, 24 Jun 2011)
New Revision: 134
Url: http://nuiton.org/repositories/revision/scmwebeditor/134
Log:
ScmWebEditor delete the checkout temp dir after each action
Modified:
trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
trunk/src/main/webapp/ModificationViewer.jsp
trunk/src/main/webapp/OutConnection.jsp
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java 2011-06-23 14:15:20 UTC (rev 133)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java 2011-06-24 08:07:02 UTC (rev 134)
@@ -210,7 +210,7 @@
StringBuilder buffer = new StringBuilder();
buffer.append(svnSess.getScmEditorUrl());
buffer.append('?').append(PARAMETER_ADDRESS).append('=').append(svnSess.getSvnPath()+svnSess.getFileName());
- buffer.append("&").append(PARAMETER_PROJECT_URL).append('=').append(svnSess.getProjectUrl());
+
String url = buffer.toString();
return url;
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-23 14:15:20 UTC (rev 133)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-24 08:07:02 UTC (rev 134)
@@ -1,6 +1,7 @@
package org.nuiton.scmwebeditor.actions;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
@@ -17,7 +18,11 @@
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.wc.SVNCommitClient;
+import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.wc.SVNUpdateClient;
+
+
public class ScmWebEditorCommitAction extends ScmWebEditorBaseAction implements ServletRequestAware {
/**
*
@@ -31,6 +36,8 @@
protected String origText;
protected String username;
protected String pw;
+ protected String address;
+ protected String lastText;
protected HttpServletRequest request;
@@ -43,7 +50,6 @@
this.commitMessage = commitMessage;
}
-
public String getNewText() {
return newText;
}
@@ -75,7 +81,24 @@
public void setPw(String pw) {
this.pw = pw;
}
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+ public String getLastText() {
+ return lastText;
+ }
+
+ public void setLastText(String lastText) {
+ this.lastText = lastText;
+ }
+
+
public String execute() {
System.setProperty("file.encoding", "UTF-8");
HttpSession httpSession = request.getSession(true);
@@ -86,6 +109,75 @@
svnSess.getLogin() != null && !svnSess.getLogin().equalsIgnoreCase("") ? svnSess.getLogin() : username,
svnSess.getPassword() != null && !svnSess.getPassword().equalsIgnoreCase("") ? svnSess.getPassword() : pw);
+
+
+ /*
+ * Checkout process
+ */
+ SVNUpdateClient upclient = new SVNUpdateClient(svnSess.getManager(), svnSess.getSvnOption());
+
+
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Do Checkout of " + svnSess.getRemoteUrl());
+ }
+ upclient.doCheckout(svnSess.getRemoteUrl(), svnSess.getCheckoutdir(),
+ SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.FILES, false);
+ } catch (SVNAuthenticationException authexep) {
+ request.setAttribute(PARAMETER_ADDRESS, address);
+
+ // if svn authentication failed user is redirected on login page
+ if(log.isDebugEnabled()) {
+ log.debug("Private SCM on reading " + svnSess.getRemoteUrl());
+ }
+ //On supprime le repertoire temporaire
+ delTempDirectory(svnSess);
+ //redirect to a login page
+ return "authError";
+
+ } catch (SVNException e) {
+ //Suppression du repertoire temporaire
+ delTempDirectory(svnSess);
+ return "error";
+ }
+ lastText=newText;
+
+ File CheckOutFile = new File(svnSess.getCheckoutdir(), svnSess.getFileName());
+ try {
+ String originalText = FileUtils.readFileToString(CheckOutFile);
+ request.setAttribute(PARAMETER_FORMAT, svnSess.getFormat());
+ request.setAttribute("lastText", lastText);
+ request.setAttribute(ATTRIBUTE_ORIG_TEXT, StringEscapeUtils.escapeHtml(originalText));
+ request.setAttribute(ATTRIBUTE_INVALIDATE_MAX_TIME, (httpSession.getMaxInactiveInterval() / 60));
+ request.setAttribute(ATTRIBUTE_LOGIN, (svnSess.getLogin() != null && !svnSess.getLogin().equalsIgnoreCase("") ? svnSess.getLogin() : null));
+ request.setAttribute(ATTRIBUTE_IS_LOGIN, (svnSess.getLogin() != null && svnSess.getPassword() != null && !svnSess.getLogin().equalsIgnoreCase("") && !svnSess.getPassword().equalsIgnoreCase("")));
+ request.setAttribute(ATTRIBUTE_PROJECT_URL, svnSess.getProjectUrl());
+ request.setAttribute(PARAMETER_SCM_EDITOR_URL, svnSess.getScmEditorUrl());
+ if (log.isDebugEnabled()) {
+ log.debug("l'url est : " + svnSess.getScmEditorUrl());
+ }
+ request.setAttribute(ATTRIBUTE_SCM_EDITOR_URI, request.getRequestURI());
+ request.setAttribute(ATTRIBUTE_PREVIEW_SERVLET_URL, request.getContextPath() + "/previewservlet");
+
+ // End on first part
+
+ } catch (FileNotFoundException ee) {
+ /* fichier non trouve, on redirige vers BadFileRedirect.jsp
+ * après avoir supprimé le repertoire temporaire
+ */
+ delTempDirectory(svnSess);
+ request.setAttribute(PARAMETER_SCM_EDITOR_URL, svnSess.getProjectUrl());
+ return "error";
+ } catch (IOException e) {
+ log.error("Can't find the checkout file",e);
+ }
+
+
+
+ /*
+ * Commit process
+ */
+
String originalText = StringEscapeUtils.unescapeHtml(origText);
String myText = StringEscapeUtils.unescapeHtml(newText);
@@ -98,7 +190,7 @@
if(log.isErrorEnabled()) {
log.error("Can't write in file " , e);
}
- return "ko";
+ return "erreur";
}
@@ -108,45 +200,48 @@
tabFile[0] = pathToFile;
// Sending Data to SVN
- if (!myText.equals(originalText)) {
- try {
- if(log.isDebugEnabled()) {
- log.debug("Try to commit");
- }
- commitClient.doCommit(tabFile, false, "From scmwebeditor -- "+commitMessage, null, null, false, true, SVNDepth.FILES);
- } catch (SVNAuthenticationException authexep) {
- if(log.isErrorEnabled()) {
- log.error("AUTH FAIL",authexep);
- }
- svnSess.setLogin(null);
- svnSess.setPassword(null);
- // if authentication failed edition page is reload form user's relogin
- request.setAttribute(PARAMETER_FORMAT, svnSess.getFormat());
- request.setAttribute(ATTRIBUTE_ORIG_TEXT, StringEscapeUtils.escapeHtml(newText));
- request.setAttribute(ATTRIBUTE_INVALIDATE_MAX_TIME, (httpSession.getMaxInactiveInterval() / 60));
- request.setAttribute(ATTRIBUTE_LOGIN, (svnSess.getLogin() != null && !svnSess.getLogin().equalsIgnoreCase("") ? svnSess.getLogin() : null));
- request.setAttribute(ATTRIBUTE_IS_LOGIN, false);
- request.setAttribute(ATTRIBUTE_PROJECT_URL, svnSess.getProjectUrl());
- request.setAttribute(PARAMETER_SCM_EDITOR_URL, svnSess.getScmEditorUrl());
- request.setAttribute(ATTRIBUTE_SCM_EDITOR_URI, request.getRequestURI());
- request.setAttribute(ATTRIBUTE_PREVIEW_SERVLET_URL, request.getContextPath() + "/previewservlet");
-
- request.setAttribute(ATTRIBUTE_BAD_LOGIN, true);
- return "authError";
- } catch (SVNException e) {
- if(log.isErrorEnabled()) {
- log.error("SVN FAIL",e);
- }
- //Suppression du repertoire temporaire
- //delTempDirectory(svnSess);
- request.setAttribute(ATTRIBUTE_REDIRECT_URL, getRedirectUrl(svnSess));
- return "erreur";
+
+ try {
+ if(log.isDebugEnabled()) {
+ log.debug("Try to commit");
}
+ commitClient.doCommit(tabFile, false, "From scmwebeditor -- "+commitMessage, null, null, false, true, SVNDepth.FILES);
+ } catch (SVNAuthenticationException authexep) {
+ if(log.isErrorEnabled()) {
+ log.error("AUTH FAIL");
+ }
+ svnSess.setLogin(null);
+ svnSess.setPassword(null);
+ // if authentication failed edition page is reload form user's relogin
+ request.setAttribute("address", address);
+ request.setAttribute(PARAMETER_FORMAT, svnSess.getFormat());
+ request.setAttribute(ATTRIBUTE_ORIG_TEXT, StringEscapeUtils.escapeHtml(newText));
+ request.setAttribute(ATTRIBUTE_INVALIDATE_MAX_TIME, (httpSession.getMaxInactiveInterval() / 60));
+ request.setAttribute(ATTRIBUTE_LOGIN, (svnSess.getLogin() != null && !svnSess.getLogin().equalsIgnoreCase("") ? svnSess.getLogin() : null));
+ request.setAttribute(ATTRIBUTE_IS_LOGIN, false);
+ request.setAttribute(ATTRIBUTE_PROJECT_URL, svnSess.getProjectUrl());
+ request.setAttribute(PARAMETER_SCM_EDITOR_URL, svnSess.getScmEditorUrl());
+ request.setAttribute(ATTRIBUTE_SCM_EDITOR_URI, request.getRequestURI());
+ request.setAttribute(ATTRIBUTE_PREVIEW_SERVLET_URL, request.getContextPath() + "/previewservlet");
+
+ request.setAttribute(ATTRIBUTE_BAD_LOGIN, true);
+ //Suppression du repertoire temporaire
+ delTempDirectory(svnSess);
+ return "authError";
+ } catch (SVNException e) {
+ if(log.isErrorEnabled()) {
+ log.error("SVN FAIL",e);
+ }
+ //Suppression du repertoire temporaire
+ delTempDirectory(svnSess);
+ request.setAttribute(ATTRIBUTE_REDIRECT_URL, getRedirectUrl(svnSess));
+ return "erreur";
}
+
if (svnSess.getCheckoutdir() != null) {
//Suppression du repertoire temporaire
- //delTempDirectory(svnSess);
+ delTempDirectory(svnSess);
}
//if commit success user is redirect on the project page
request.setAttribute(ATTRIBUTE_REDIRECTION_URL, svnSess.getProjectUrl());
@@ -155,7 +250,7 @@
log.debug("End of commit");
}
//Suppression du repertoire temporaire
- //delTempDirectory(svnSess);
+ delTempDirectory(svnSess);
return "success";
}
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-23 14:15:20 UTC (rev 133)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-24 08:07:02 UTC (rev 134)
@@ -21,6 +21,8 @@
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;
+import com.opensymphony.xwork2.Action;
+
public class ScmWebEditorMainAction extends ScmWebEditorBaseAction implements ServletRequestAware {
/**
@@ -178,9 +180,10 @@
if(log.isDebugEnabled()) {
log.debug("Private SCM on reading " + svnSess.getRemoteUrl());
}
-
+ //On supprime le repertoire temporaire
+ delTempDirectory(svnSess);
//redirect to a login page
- return "login";
+ return Action.LOGIN;
} catch (SVNException e) {
//Suppression du repertoire temporaire
@@ -218,6 +221,8 @@
log.error("Can't find the checkout file",e);
}
+ //On supprime le repertoire temporaire
+ delTempDirectory(svnSess);
return "editPage";
Modified: trunk/src/main/webapp/ModificationViewer.jsp
===================================================================
--- trunk/src/main/webapp/ModificationViewer.jsp 2011-06-23 14:15:20 UTC (rev 133)
+++ trunk/src/main/webapp/ModificationViewer.jsp 2011-06-24 08:07:02 UTC (rev 134)
@@ -21,7 +21,11 @@
<center>
<form method="post" action=commit.action id="editForm">
<script src="GereFormSize.js" type="text/javascript"></script>
- <textarea name="newText" id="newText"><%=request.getAttribute("OrigText")%></textarea>
+ <% if(request.getAttribute("lastText")!=null) { %>
+ <textarea name="newText" id="newText"><%=request.getAttribute("lastText")%></textarea>
+ <% } else { %>
+ <textarea name="newText" id="newText"><%=request.getAttribute("OrigText")%></textarea>
+ <% } %>
<script src="GereSession.js" type="text/javascript"></script>
<script src="cancelRedirectDelete.js" type="text/javascript"></script>
<script src="pictureUpload.js" type="text/javascript"></script>
@@ -50,10 +54,13 @@
<input type="hidden" NAME=username />
<input type="hidden" NAME=pw /><%
}%>
+ <input type="hidden" name="address" value="<%=request.getAttribute("address")%>"/>
<input type="hidden" name="origText" value="<%=request.getAttribute("OrigText")%>"/>
+ <% if(request.getAttribute("lastText")!=null) { %>
+ <input type="hidden" name="lastText" value="<%=request.getAttribute("lastText")%>" />
+ <% } %>
<input type="hidden" name="scmEditorUrl" value="<%=request.getAttribute("scmEditorUrl")%>"/>
- <input type="hidden" name="previewServletUrl" value="<%=request.getAttribute("previewServletUrl")%>"/>
-
+
<s:url id="ajaxCommit" value="save.action" />
<sj:submit
Modified: trunk/src/main/webapp/OutConnection.jsp
===================================================================
--- trunk/src/main/webapp/OutConnection.jsp 2011-06-23 14:15:20 UTC (rev 133)
+++ trunk/src/main/webapp/OutConnection.jsp 2011-06-24 08:07:02 UTC (rev 134)
@@ -45,10 +45,6 @@
<input type="submit" name="Save" />
</p>
-
-
-
-
<div id="htmlcontentSearch" ></div>
</form>
</center>
1
0
r133 - in trunk/src/main: java/org/nuiton/scmwebeditor/actions resources webapp
by kcardineaud@users.nuiton.org 23 Jun '11
by kcardineaud@users.nuiton.org 23 Jun '11
23 Jun '11
Author: kcardineaud
Date: 2011-06-23 16:15:20 +0200 (Thu, 23 Jun 2011)
New Revision: 133
Url: http://nuiton.org/repositories/revision/scmwebeditor/133
Log:
Add the upload file function
Added:
trunk/src/main/java/org/nuiton/scmwebeditor/actions/UploadAction.java
trunk/src/main/webapp/uploadForm.jsp
trunk/src/main/webapp/uploadSuccess.jsp
Modified:
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/ModificationViewer.jsp
trunk/src/main/webapp/accueil.jsp
trunk/src/main/webapp/pictureUpload.js
Added: trunk/src/main/java/org/nuiton/scmwebeditor/actions/UploadAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/UploadAction.java (rev 0)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/UploadAction.java 2011-06-23 14:15:20 UTC (rev 133)
@@ -0,0 +1,143 @@
+package org.nuiton.scmwebeditor.actions;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.interceptor.ServletRequestAware;
+import org.nuiton.scmwebeditor.ScmWebEditorBaseAction;
+import org.nuiton.scmwebeditor.SvnSession;
+import org.tmatesoft.svn.core.SVNAuthenticationException;
+import org.tmatesoft.svn.core.SVNDepth;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.wc.SVNClientManager;
+
+import com.opensymphony.xwork2.Action;
+
+public class UploadAction extends ScmWebEditorBaseAction implements ServletRequestAware {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4244339447567114412L;
+ private static final Log log = LogFactory.getLog(UploadAction.class);
+ protected File upload;
+ protected String uploadFileName;
+ protected String uploadContentType;
+ protected String username;
+ protected String pw;
+ protected String svnPath;
+
+ protected HttpServletRequest request;
+
+
+ public String getSvnPath() {
+ return svnPath;
+ }
+ public void setSvnPath(String svnPath) {
+ this.svnPath = svnPath;
+ }
+ public File getUpload() {
+ return upload;
+ }
+ public void setUpload(File upload) {
+ this.upload = upload;
+ }
+ public String getUploadContentType() {
+ return uploadContentType;
+ }
+ public void setUploadContentType(String uploadContentType) {
+ this.uploadContentType = uploadContentType;
+ }
+ public String getUploadFileName() {
+ return uploadFileName;
+ }
+ public void setUploadFileName(String uploadFileName) {
+ this.uploadFileName = uploadFileName;
+ }
+ public String getUsername() {
+ return username;
+ }
+ public void setUsername(String username) {
+ this.username = username;
+ }
+ public String getPw() {
+ return pw;
+ }
+ public void setPw(String pw) {
+ this.pw = pw;
+ }
+
+
+ public String execute() {
+
+ if(log.isInfoEnabled()) {
+ log.info("PictureName : "+uploadFileName);
+ log.info("ContentType : "+uploadContentType);
+ }
+
+
+
+
+ HttpSession httpSession = request.getSession(true);
+ SvnSession svnSess = getSvnSession(httpSession);
+
+ File checkoutDir = svnSess.getCheckoutdir();
+
+ String checkoutPath = checkoutDir.getAbsolutePath();
+ File file = new File(checkoutPath,uploadFileName);
+
+
+ try {
+ FileUtils.copyFile(upload, file);
+ } catch (IOException e) {
+ log.error("Can't copy the file to the checkout directory",e);
+ }
+
+
+// Resetting authentification information and manager
+ svnSess.updateAuthentication(
+ svnSess.getLogin() != null && !svnSess.getLogin().equalsIgnoreCase("") ? svnSess.getLogin() : username,
+ svnSess.getPassword() != null && !svnSess.getPassword().equalsIgnoreCase("") ? svnSess.getPassword() : pw);
+
+
+
+ SVNClientManager manager = svnSess.getManager();
+
+ File[] tabFile = new File[1];
+ tabFile[0] = file;
+
+ try {
+ //On ajoute l'image aux fichiers versionnés
+ manager.getWCClient().doAdd( file , false , false , false , SVNDepth.FILES, false, false );
+ //On commit la modification
+ manager.getCommitClient().doCommit(tabFile, false, "From scmwebeditor -- add the file : "+uploadFileName, null, null, false, true, SVNDepth.FILES);
+ } catch (SVNAuthenticationException authexep) {
+ log.error("authentification fail");
+ request.setAttribute(ATTRIBUTE_BAD_LOGIN, true);
+ return Action.LOGIN;
+ }
+ catch (SVNException e) {
+ log.error("Erreur SVN",e);
+ request.setAttribute("error", true);
+ return Action.ERROR;
+ }
+
+
+ return Action.SUCCESS;
+ }
+
+
+ @Override
+ public void setServletRequest(HttpServletRequest request) {
+ this.request=request;
+ }
+
+
+
+}
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-06-22 15:16:18 UTC (rev 132)
+++ trunk/src/main/resources/struts.xml 2011-06-23 14:15:20 UTC (rev 133)
@@ -11,20 +11,31 @@
<result name="erreurPath" >/BadFileRedirect.jsp</result>
<result name="editPage" >/ModificationViewer.jsp</result>
</action>
+
<action name="commit" class="org.nuiton.scmwebeditor.actions.ScmWebEditorCommitAction" method="execute">
<result name="success" >/Redirect.jsp</result>
<result name="authError" >/ModificationViewer.jsp</result>
<result name="erreur">/BadFileRedirect.jsp</result>
</action>
+
<action name="save" class="org.nuiton.scmwebeditor.actions.SaveAction" method="save">
<result>/Save.jsp</result>
</action>
+
+ <action name="doUpload" class="org.nuiton.scmwebeditor.actions.UploadAction" method="execute">
+ <result>/uploadSuccess.jsp</result>
+ <result name="login" >/uploadForm.jsp</result>
+ <result name="error" >/uploadForm.jsp</result>
+ </action>
+
<action name="preview" class="org.nuiton.scmwebeditor.actions.PreviewAction" method="execute">
<result>/Preview.jsp</result>
</action>
+
<action name="search" class="org.nuiton.scmwebeditor.actions.SearchAction" method="search">
<result>/Search.jsp</result>
<result name="authError" >/LoginSearch.jsp</result>
</action>
+
</package>
</struts>
\ No newline at end of file
Modified: trunk/src/main/webapp/ModificationViewer.jsp
===================================================================
--- trunk/src/main/webapp/ModificationViewer.jsp 2011-06-22 15:16:18 UTC (rev 132)
+++ trunk/src/main/webapp/ModificationViewer.jsp 2011-06-23 14:15:20 UTC (rev 133)
@@ -93,11 +93,35 @@
<input title="Exit ScmWebEditor without saving." type="button" value="Exit" name="Cancel" onclick="javascript:cancelRedirectDelete(this.form.origText, this.form.username, this.form.pw, this.form.commitMessage, this.form.ProjectUrl, this.form.scmEditorUrl);"/>
</form>
-
-
-
-
+
+ <button onClick="javascript:upload_popup('uploadForm.jsp','upload');" >Upload</button>
+
+ <!--
+ <form method="POST" id="uploadForm" action="doUpload" enctype="multipart/form-data">
+
+ <label>Upload File : <input type=file name="upload" /></label>
+ <input type="submit">
+
+
+ <s:file name="upload" label="File"/>
+
+
+
+ <sj:submit
+ id="ajaxUploadButton"
+ targets="htmlcontentUpload"
+ button="true"
+ value="upload"
+ >
+ </sj:submit>
+
+
+ </form>
+ -->
+
+ <sj:div id="htmlcontentUpload"></sj:div>
</center>
+
<div id="htmlcontentPreview"></div>
<p align="right">©2004-2009 CodeLutin</p>
Modified: trunk/src/main/webapp/accueil.jsp
===================================================================
--- trunk/src/main/webapp/accueil.jsp 2011-06-22 15:16:18 UTC (rev 132)
+++ trunk/src/main/webapp/accueil.jsp 2011-06-23 14:15:20 UTC (rev 133)
@@ -1,9 +1,3 @@
<%@ page contentType="text/html; charset=UTF-8" %>
-<html>
- <head>
- </head>
- <body>
<p>Parametres detectés</p>
- </body>
-</html>
\ No newline at end of file
Modified: trunk/src/main/webapp/pictureUpload.js
===================================================================
--- trunk/src/main/webapp/pictureUpload.js 2011-06-22 15:16:18 UTC (rev 132)
+++ trunk/src/main/webapp/pictureUpload.js 2011-06-23 14:15:20 UTC (rev 133)
@@ -0,0 +1,4 @@
+function upload_popup(page, name)
+{
+window.open (page, name, config='top=300, left=300, height=300, width=500, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
+}
\ No newline at end of file
Added: trunk/src/main/webapp/uploadForm.jsp
===================================================================
--- trunk/src/main/webapp/uploadForm.jsp (rev 0)
+++ trunk/src/main/webapp/uploadForm.jsp 2011-06-23 14:15:20 UTC (rev 133)
@@ -0,0 +1,34 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ 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>UploadFile</title>
+</head>
+<body>
+
+ <form method="POST" id="uploadForm" action="doUpload" enctype="multipart/form-data">
+ <label>Upload a picture : <input type="file" name="upload"/></label><br/>
+ <label>Path on svn : <input type="text" name="svnPath" /></label><br/>
+ <label>username : <input type="text" name="username" /></label><br/>
+ <label>password : <input type="password" name="pw" /></label><br/>
+ <%if (request.getAttribute("badLogin")!=null && request.getAttribute("badLogin").equals(true)) { %>
+ <p>
+ <font color="red">
+ Bad username or password
+ </font>
+ </p>
+ <% } %>
+ <%if (request.getAttribute("error")!=null && request.getAttribute("error").equals(true)) { %>
+ <p>
+ <font color="red">
+ Erreur SVN
+ </font>
+ </p>
+ <% } %>
+ <input type="submit"/>
+ </form>
+
+</body>
+</html>
\ No newline at end of file
Added: trunk/src/main/webapp/uploadSuccess.jsp
===================================================================
--- trunk/src/main/webapp/uploadSuccess.jsp (rev 0)
+++ trunk/src/main/webapp/uploadSuccess.jsp 2011-06-23 14:15:20 UTC (rev 133)
@@ -0,0 +1,15 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ 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>Success</title>
+</head>
+<body>
+<p>File upload successful</p>
+ <form>
+ <input type="button" value="close" onclick="window.close()">
+ </form>
+</body>
+</html>
\ No newline at end of file
1
0
r132 - in trunk/src/main: java/org/nuiton/scmwebeditor java/org/nuiton/scmwebeditor/actions resources webapp webapp/css
by kcardineaud@users.nuiton.org 22 Jun '11
by kcardineaud@users.nuiton.org 22 Jun '11
22 Jun '11
Author: kcardineaud
Date: 2011-06-22 17:16:18 +0200 (Wed, 22 Jun 2011)
New Revision: 132
Url: http://nuiton.org/repositories/revision/scmwebeditor/132
Log:
ScmWebEditor can now be use with read/write private SVN
Added:
trunk/src/main/webapp/LoginSearch.jsp
Modified:
trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/ModificationViewer.jsp
trunk/src/main/webapp/OutConnection.jsp
trunk/src/main/webapp/PrivateSvnRedirect.jsp
trunk/src/main/webapp/Search.jsp
trunk/src/main/webapp/css/main.css
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java 2011-06-22 12:46:07 UTC (rev 131)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java 2011-06-22 15:16:18 UTC (rev 132)
@@ -51,7 +51,7 @@
private static final Log log = LogFactory.getLog(ScmWebEditorBaseAction.class);
//TODO-TC200924 : uniformize all this different parameter and attribute, this is a bit messy...
- protected static final String PARAMETER_ADRESSE = "address";
+ protected static final String PARAMETER_ADDRESS = "address";
protected static final String PARAMETER_SCM_EDITOR_URL = "scmEditorUrl";
protected static final String PARAMETER_PROJECT_URL = "projectUrl";
protected static final String PARAMETER_FILE_NAME = "file_name";
@@ -209,7 +209,7 @@
protected String getRedirectUrl(SvnSession svnSess) {
StringBuilder buffer = new StringBuilder();
buffer.append(svnSess.getScmEditorUrl());
- buffer.append('?').append(PARAMETER_ADRESSE).append('=').append(svnSess.getSvnPath()+svnSess.getFileName());
+ buffer.append('?').append(PARAMETER_ADDRESS).append('=').append(svnSess.getSvnPath()+svnSess.getFileName());
buffer.append("&").append(PARAMETER_PROJECT_URL).append('=').append(svnSess.getProjectUrl());
String url = buffer.toString();
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-22 12:46:07 UTC (rev 131)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-22 15:16:18 UTC (rev 132)
@@ -34,10 +34,33 @@
protected String projectUrl;
protected String format;
+
+ protected String username;
+ protected String pw;
+
protected HttpServletRequest request;
+ public String getUsername() {
+ return username;
+ }
+
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+
+ public String getPw() {
+ return pw;
+ }
+
+
+ public void setPw(String pw) {
+ this.pw = pw;
+ }
+
public String getAddress() {
return address;
}
@@ -104,30 +127,33 @@
//SvnSession object creation if doesn't already exist
SvnSession svnSess = getSvnSession(httpSession);
+
String relativePath = address.substring(0,address.lastIndexOf("/"));
String scmFileName = address.substring(address.lastIndexOf("/")+1);
+
format = scmFileName.substring(scmFileName.lastIndexOf(".")+1);
+
+
String tmp_log = null;
String tmp_pass = null;
- if (svnSess != null) {
- tmp_log = svnSess.getLogin();
- tmp_pass = svnSess.getPassword();
- }
- svnSess = new SvnSession(
- relativePath,
- scmFileName,
- projectUrl,
- tmp_log,
- tmp_pass,
- httpSession.getId(),
- format,
- request.getRequestURL());
-
-
+ svnSess = new SvnSession(
+ relativePath,
+ scmFileName,
+ projectUrl,
+ tmp_log,
+ tmp_pass,
+ httpSession.getId(),
+ format,
+ request.getRequestURL());
+
+ svnSess.updateAuthentication(
+ svnSess.getLogin() != null && !svnSess.getLogin().equalsIgnoreCase("") ? svnSess.getLogin() : username,
+ svnSess.getPassword() != null && !svnSess.getPassword().equalsIgnoreCase("") ? svnSess.getPassword() : pw);
+
setSvnSession(httpSession, svnSess);
// Tempdir creation on servlet default temporary directory
@@ -146,12 +172,13 @@
upclient.doCheckout(svnSess.getRemoteUrl(), svnSess.getCheckoutdir(),
SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.FILES, false);
} catch (SVNAuthenticationException authexep) {
+ request.setAttribute(PARAMETER_ADDRESS, address);
+
// if svn authentication failed user is redirected on login page
if(log.isDebugEnabled()) {
log.debug("Private SCM on reading " + svnSess.getRemoteUrl());
}
- //Suppression du repertoire temporaire
- delTempDirectory(svnSess);
+
//redirect to a login page
return "login";
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java 2011-06-22 12:46:07 UTC (rev 131)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java 2011-06-22 15:16:18 UTC (rev 132)
@@ -1,13 +1,13 @@
package org.nuiton.scmwebeditor.actions;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.scmwebeditor.ScmWebEditorBaseAction;
+import org.tmatesoft.svn.core.SVNAuthenticationException;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNNodeKind;
@@ -37,11 +37,15 @@
String address;
LinkedList<String> files;
-
+ String username;
+ String pw;
+
+
String info;
String list;
+
public String getList() {
return list;
}
@@ -71,22 +75,41 @@
this.address = address;
}
-
- public String execute() {
- search();
- return Action.SUCCESS;
+ public String getUsername() {
+ return username;
}
-
-
- public void search() {
+
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+
+ public String getPw() {
+ return pw;
+ }
+
+
+ public void setPw(String pw) {
+ this.pw = pw;
+ }
+
+
+ public String search() {
DAVRepositoryFactory.setup();
String url = address;
+
String name = "anonymous";
String password="anonymous";
+ if(username!=null && pw!=null) {
+ name = username;
+ password=pw;
+ }
+
files = new LinkedList<String>();
@@ -111,26 +134,36 @@
if(log.isErrorEnabled()) {
log.error( "There is no entry at '" + url + "'." );
}
- return;
+ return Action.SUCCESS;
} else if ( nodeKind == SVNNodeKind.FILE ) {
if(log.isErrorEnabled()) {
log.error( "The entry at '" + url + "' is a file while a directory was expected." );
}
- return;
+ return Action.SUCCESS;
}
listEntries( repository , "" );
- } catch ( Exception svne ) {
+ } catch (SVNAuthenticationException authexep) {
+ return "authError";
+ }
+ catch ( SVNException svne ) {
log.error("Can't access to the repository",svne);
}
+ return Action.SUCCESS;
}
- public void listEntries( SVNRepository repository, String path ) throws SVNException {
- Collection<?> entries = repository.getDir( path, -1 , null , (Collection<?>) null );
+ public void listEntries( SVNRepository repository, String path ) {
+ Collection<?> entries = null;
+ try {
+ entries = repository.getDir( path, -1 , null , (Collection<?>) null );
+ } catch (SVNException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
Iterator<?> iterator = entries.iterator();
while (iterator.hasNext()) {
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-06-22 12:46:07 UTC (rev 131)
+++ trunk/src/main/resources/struts.xml 2011-06-22 15:16:18 UTC (rev 132)
@@ -22,8 +22,9 @@
<action name="preview" class="org.nuiton.scmwebeditor.actions.PreviewAction" method="execute">
<result>/Preview.jsp</result>
</action>
- <action name="search" class="org.nuiton.scmwebeditor.actions.SearchAction" method="execute">
+ <action name="search" class="org.nuiton.scmwebeditor.actions.SearchAction" method="search">
<result>/Search.jsp</result>
+ <result name="authError" >/LoginSearch.jsp</result>
</action>
</package>
</struts>
\ No newline at end of file
Added: trunk/src/main/webapp/LoginSearch.jsp
===================================================================
--- trunk/src/main/webapp/LoginSearch.jsp (rev 0)
+++ trunk/src/main/webapp/LoginSearch.jsp 2011-06-22 15:16:18 UTC (rev 132)
@@ -0,0 +1,28 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+ <%@ taglib prefix="s" uri="/struts-tags"%>
+ <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
+ <sj:head jquerytheme="default"/>
+
+<div id="search">
+ <p>You must be login to see this repository.</p>
+ <p>
+ <label>Username : <input type="text" name="username"></input></label><br/>
+ <label>Password : <input type ="password" name="pw"></input></label><br/>
+
+ <s:url id="ajaxSearchLogin" value="search.action" />
+
+ <sj:submit
+ id="ajaxSearchButtonLogin"
+ formIds="configForm"
+ targets="htmlcontentSearch"
+ href="%{ajaxSearchLogin}"
+ indicator="indicator"
+ button="true"
+ buttonIcon="ui-icon-refresh"
+ value="Login"
+ >
+ </sj:submit>
+ </p>
+</div>
\ No newline at end of file
Modified: trunk/src/main/webapp/ModificationViewer.jsp
===================================================================
--- trunk/src/main/webapp/ModificationViewer.jsp 2011-06-22 12:46:07 UTC (rev 131)
+++ trunk/src/main/webapp/ModificationViewer.jsp 2011-06-22 15:16:18 UTC (rev 132)
@@ -88,20 +88,15 @@
<%}%>
- <input title="Reset text as current repository HEAD revision." type="reset" value="Reset" name="Reset" alt="Test plop plop plop"/>
+ <input title="Reset text as current repository HEAD revision." type="reset" value="Reset" name="Reset" />
<input type="hidden" value="<%=request.getAttribute("ProjectUrl")%>" name="ProjectUrl">
<input title="Exit ScmWebEditor without saving." type="button" value="Exit" name="Cancel" onclick="javascript:cancelRedirectDelete(this.form.origText, this.form.username, this.form.pw, this.form.commitMessage, this.form.ProjectUrl, this.form.scmEditorUrl);"/>
-
-
-
-
</form>
-
+
-
-
-
+
+
</center>
<div id="htmlcontentPreview"></div>
Modified: trunk/src/main/webapp/OutConnection.jsp
===================================================================
--- trunk/src/main/webapp/OutConnection.jsp 2011-06-22 12:46:07 UTC (rev 131)
+++ trunk/src/main/webapp/OutConnection.jsp 2011-06-22 15:16:18 UTC (rev 132)
@@ -42,12 +42,15 @@
>
</sj:submit>
+ <input type="submit" name="Save" />
</p>
+
+
+
+
<div id="htmlcontentSearch" ></div>
-
-<input type="hidden" name="projectUrl" value="<%=request.getHeader("referer")%>" />
-<input type="submit" name="Save" /></form>
+</form>
</center>
<p align="right">©2004-2009 CodeLutin</p>
</body>
Modified: trunk/src/main/webapp/PrivateSvnRedirect.jsp
===================================================================
--- trunk/src/main/webapp/PrivateSvnRedirect.jsp 2011-06-22 12:46:07 UTC (rev 131)
+++ trunk/src/main/webapp/PrivateSvnRedirect.jsp 2011-06-22 15:16:18 UTC (rev 132)
@@ -14,6 +14,8 @@
<body>
<a target="_blank" href="http://maven-site.nuiton.org/scmwebeditor/"><img src="img/ScmWebEditor_main.png" alt="$alt" /></a>
<form method="post" action="checkout.action" >
+<input type="hidden" name="address" value="<%=request.getAttribute("address")%>"/>
+<input type="hidden" name="projectUrl" value="<%=request.getAttribute("projectUrl")%>"/>
<script src="cancelRedirect.js"></script>
<p>You try to access a Private SCM. Please login</p>
<p><label ACCESSKEY=U>User name: <input TYPE=text
Modified: trunk/src/main/webapp/Search.jsp
===================================================================
--- trunk/src/main/webapp/Search.jsp 2011-06-22 12:46:07 UTC (rev 131)
+++ trunk/src/main/webapp/Search.jsp 2011-06-22 15:16:18 UTC (rev 132)
@@ -7,21 +7,24 @@
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<sj:head jquerytheme="default"/>
-<table>
- <%
- SearchAction action = SearchAction.getAction();
-
- LinkedList<String> files = action.getFiles();
-
- Iterator<String> it = files.iterator();
-
- while(it.hasNext()) {
- String file = it.next();
- %>
- <tr><td>
- <a href="checkout.action?address=<%=file%>&projectUrl="<%=request.getRequestURL()%>" ><%=file%></a>
+<div id="search">
+<p>Files in the SVN repository : </p>
+ <table>
+ <%
+ SearchAction action = SearchAction.getAction();
+
+ LinkedList<String> files = action.getFiles();
- </td></tr>
- <% } %>
-
-</table>
\ No newline at end of file
+ Iterator<String> it = files.iterator();
+
+ while(it.hasNext()) {
+ String file = it.next();
+ %>
+ <tr><td>
+ <a href="checkout.action?address=<%=file%>&projectUrl="<%=request.getRequestURL()%>" ><%=file%></a>
+
+ </td></tr>
+ <% } %>
+
+ </table>
+</div>
\ No newline at end of file
Modified: trunk/src/main/webapp/css/main.css
===================================================================
--- trunk/src/main/webapp/css/main.css 2011-06-22 12:46:07 UTC (rev 131)
+++ trunk/src/main/webapp/css/main.css 2011-06-22 15:16:18 UTC (rev 132)
@@ -23,3 +23,9 @@
border : solid 3px black;
}
+#search {
+ width:30%;
+ margin:auto;
+ display:block;
+ border : solid 2px black;
+}
1
0
r131 - in trunk/src/main: java/org/nuiton/scmwebeditor java/org/nuiton/scmwebeditor/actions resources webapp
by kcardineaud@users.nuiton.org 22 Jun '11
by kcardineaud@users.nuiton.org 22 Jun '11
22 Jun '11
Author: kcardineaud
Date: 2011-06-22 14:46:07 +0200 (Wed, 22 Jun 2011)
New Revision: 131
Url: http://nuiton.org/repositories/revision/scmwebeditor/131
Log:
Add a search function
Added:
trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java
trunk/src/main/webapp/Search.jsp
Removed:
trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java
Modified:
trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
trunk/src/main/resources/log4j.properties
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/BadFileRedirect.jsp
trunk/src/main/webapp/OutConnection.jsp
trunk/src/main/webapp/Save.jsp
Deleted: trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java 2011-06-21 12:56:58 UTC (rev 130)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java 2011-06-22 12:46:07 UTC (rev 131)
@@ -1,101 +0,0 @@
-/*
- * #%L
- * Nuiton-ScmWebEditor
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.scmwebeditor;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.tmatesoft.svn.core.ISVNDirEntryHandler;
-import org.tmatesoft.svn.core.SVNDirEntry;
-import org.tmatesoft.svn.core.SVNException;
-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.ISVNRepositoryPool;
-import org.tmatesoft.svn.core.wc.SVNClientManager;
-import org.tmatesoft.svn.core.wc.SVNLogClient;
-import org.tmatesoft.svn.core.wc.SVNRevision;
-import org.tmatesoft.svn.core.wc.SVNWCUtil;
-
-public class SearchServlet extends ScmWebEditorBaseAction {
-
- /**
- *
- */
- private static final long serialVersionUID = 8229295563440910960L;
- private static final Log log = LogFactory.getLog(SearchServlet.class);
-
- /**
- * Handles the HTTP <code>POST</code> method.
- * Search files list on scm repository
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- */
-
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
- try {
- String adresse = request.getParameter(PARAMETER_ADRESSE);
- if (log.isDebugEnabled()) {
- log.debug("Search for files on " + adresse + " repository");
- }
- //Create default access
- DefaultSVNOptions svnOption = SVNWCUtil.createDefaultOptions(false);
- ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager();
- log.debug("Authentication manager and svnOption created");
- //Convert url to SVNUrl
- SVNURL svnUrl = SVNURL.parseURIEncoded(adresse);
- log.debug("Svn url created");
- // create a SVNRepositoryPool
- SVNClientManager plop = SVNClientManager.newInstance(svnOption, authManager);
- ISVNRepositoryPool pool = plop.getRepositoryPool();
- //get a SVNLogClient
- SVNLogClient logClient = new SVNLogClient(pool, svnOption);
- log.debug("LogClient Created");
- //recup info about svn repository
- ISVNDirEntryHandler dirEntryHandler = new ISVNDirEntryHandler() {
- @Override
- public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException {
- log.debug("Handle dirEntries");
- log.debug("le fichier est: " + dirEntry.getName());
- throw new UnsupportedOperationException("Not supported yet.");
- }
- };
- log.debug("Begin handle listEntries");
- logClient.doList(svnUrl, SVNRevision.WORKING, SVNRevision.HEAD, true, true, dirEntryHandler);
- log.debug("List handle");
- } catch (SVNException ex) {
- response.setStatus(401);
- Logger.getLogger(SearchServlet.class.getName()).log(Level.SEVERE, null, ex);
- }
-
-
- }
-}
\ No newline at end of file
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-21 12:56:58 UTC (rev 130)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-22 12:46:07 UTC (rev 131)
@@ -93,6 +93,11 @@
return "noParameter";
}
+ if(log.isInfoEnabled()) {
+ log.info("ProjectUrl= "+request.getHeader("referer"));
+ }
+ projectUrl=request.getHeader("referer");
+
HttpSession httpSession = request.getSession(true);
System.setProperty("file.encoding", "UTF-8");
Added: trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java (rev 0)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/SearchAction.java 2011-06-22 12:46:07 UTC (rev 131)
@@ -0,0 +1,174 @@
+package org.nuiton.scmwebeditor.actions;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.scmwebeditor.ScmWebEditorBaseAction;
+import org.tmatesoft.svn.core.SVNDirEntry;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNNodeKind;
+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.io.SVNRepository;
+import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
+
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
+
+
+public class SearchAction extends ScmWebEditorBaseAction {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4432027215087932750L;
+
+
+ private static final Log log = LogFactory.getLog(SearchAction.class);
+
+
+ String address;
+ LinkedList<String> files;
+
+ String info;
+
+ String list;
+
+ public String getList() {
+ return list;
+ }
+
+
+ public void setList(String list) {
+ this.list = list;
+ }
+
+
+ public LinkedList<String> getFiles() {
+ return files;
+ }
+
+
+ public String getInfo() {
+ return info;
+ }
+
+
+ public String getAddress() {
+ return address;
+ }
+
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+
+ public String execute() {
+ search();
+ return Action.SUCCESS;
+ }
+
+
+ public void search() {
+
+ DAVRepositoryFactory.setup();
+
+ String url = address;
+
+ String name = "anonymous";
+ String password="anonymous";
+
+ files = new LinkedList<String>();
+
+
+ if(address.endsWith("/")) {
+ address = address.substring(0, address.length()-1);
+ }
+
+
+ SVNRepository repository = null;
+ try {
+ repository = SVNRepositoryFactory.create( SVNURL.parseURIDecoded( url ) );
+ ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( name , password );
+ repository.setAuthenticationManager( authManager );
+
+ if(log.isInfoEnabled()) {
+ log.info( "Repository Root: " + repository.getRepositoryRoot( true ) );
+ log.info( "Repository UUID: " + repository.getRepositoryUUID( true ) );
+ }
+
+ SVNNodeKind nodeKind = repository.checkPath( "" , -1 );
+ if ( nodeKind == SVNNodeKind.NONE ) {
+ if(log.isErrorEnabled()) {
+ log.error( "There is no entry at '" + url + "'." );
+ }
+ return;
+ } else if ( nodeKind == SVNNodeKind.FILE ) {
+ if(log.isErrorEnabled()) {
+ log.error( "The entry at '" + url + "' is a file while a directory was expected." );
+ }
+ return;
+ }
+
+ listEntries( repository , "" );
+
+
+ } catch ( Exception svne ) {
+ log.error("Can't access to the repository",svne);
+ }
+
+ }
+
+
+ public void listEntries( SVNRepository repository, String path ) throws SVNException {
+ Collection<?> entries = repository.getDir( path, -1 , null , (Collection<?>) null );
+ Iterator<?> iterator = entries.iterator();
+
+ while (iterator.hasNext()) {
+ SVNDirEntry entry = (SVNDirEntry) iterator.next();
+ if(log.isInfoEnabled()) {
+ log.info("/" + (path.equals("") ? "" : path + "/") + entry.getName()+ "\n");
+ info+="/" + (path.equals("") ? "" : path + "/") + entry.getName()+ "\n";
+ }
+ String fichier = address+"/" + (path.equals("") ? "" : path + "/") + entry.getName();
+
+
+ if ( entry.getKind() == SVNNodeKind.DIR ) {
+ listEntries(repository, (path.equals("")) ? entry.getName() : path + "/" + entry.getName());
+ }
+ else {
+ // On ajoute dans la liste files seulement les fichiers et pas les répertoires
+ files.add(fichier);
+ }
+ }
+
+ }
+
+
+ static public SearchAction getAction() {
+ return (SearchAction) ActionContext.getContext()
+ .get(CONTEXT_ACTION_KEY);
+ }
+
+ public static String replaceLast(String string, String toReplace, String replacement) {
+ int pos = string.lastIndexOf(toReplace);
+ if (pos > -1) {
+ return string.substring(0, pos)
+ + replacement
+ + string.substring(pos + toReplace.length(), string.length());
+ } else {
+ return string;
+ }
+ }
+
+
+}
Modified: trunk/src/main/resources/log4j.properties
===================================================================
--- trunk/src/main/resources/log4j.properties 2011-06-21 12:56:58 UTC (rev 130)
+++ trunk/src/main/resources/log4j.properties 2011-06-22 12:46:07 UTC (rev 131)
@@ -1,5 +1,5 @@
# Global logging configuration
-log4j.rootLogger=DEBUG, stdout
+log4j.rootLogger=INFO, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-06-21 12:56:58 UTC (rev 130)
+++ trunk/src/main/resources/struts.xml 2011-06-22 12:46:07 UTC (rev 131)
@@ -23,10 +23,7 @@
<result>/Preview.jsp</result>
</action>
<action name="search" class="org.nuiton.scmwebeditor.actions.SearchAction" method="execute">
- <result type="stream" >
- <param name="contentType">text/xml</param>
- <param name="inputName">XMLResponse</param>
- </result>
+ <result>/Search.jsp</result>
</action>
</package>
</struts>
\ No newline at end of file
Modified: trunk/src/main/webapp/BadFileRedirect.jsp
===================================================================
--- trunk/src/main/webapp/BadFileRedirect.jsp 2011-06-21 12:56:58 UTC (rev 130)
+++ trunk/src/main/webapp/BadFileRedirect.jsp 2011-06-22 12:46:07 UTC (rev 131)
@@ -11,13 +11,13 @@
<link rel="icon" href="img/ScmWebEditor_little.png" type="image/png">
<link rel="stylesheet" type="text/css" href="css/main.css">
<meta http-equiv="Refresh" content="3; url=
-<%=request.getParameter("scmEditorUrl")%>">
+<%=request.getParameter("projectUrl")%>">
</head>
<body>
<a target="_blank" href="http://maven-site.nuiton.org/scmwebeditor/"><img src="img/ScmWebEditor_main.png" alt="$alt" /></a>
<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="<%=request.getParameter("scmEditorUrl")%>">click
+please <a href="<%=request.getParameter("projectUrl")%>">click
this link</a>.</p>
<p>©2004-2009 CodeLutin</p>
</body>
Modified: trunk/src/main/webapp/OutConnection.jsp
===================================================================
--- trunk/src/main/webapp/OutConnection.jsp 2011-06-21 12:56:58 UTC (rev 130)
+++ trunk/src/main/webapp/OutConnection.jsp 2011-06-22 12:46:07 UTC (rev 131)
@@ -1,5 +1,9 @@
<%-- Document : OutConnection Created on : 6 oct. 2009, 12:07:27 Author: glorieux --%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
+ <%@ taglib prefix="s" uri="/struts-tags"%>
+ <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
+ <sj:head jquerytheme="default"/>
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
@@ -21,12 +25,28 @@
</h4>
</center>
<center>
-<form method="get" action="checkout.action">
- <p><label>SCM path: <input TYPE=text name="address" SIZE=100></label><input type="button" value="Search Files" name="search" onclick="javascript:fileSearch(this.form.address);"/></p>
+<form id="configForm" method="get" action="checkout.action">
+ <p><label>SCM path: <input TYPE=text name="address" SIZE=100></label>
+
+ <s:url id="ajaxSearch" value="search.action" />
+
+ <sj:submit
+ id="ajaxSearchButton"
+ formIds="configForm"
+ targets="htmlcontentSearch"
+ href="%{ajaxSearch}"
+ indicator="indicator"
+ button="true"
+ buttonIcon="ui-icon-refresh"
+ value="Search"
+ >
+ </sj:submit>
+
+ </p>
+<div id="htmlcontentSearch" ></div>
-<input type="hidden" name="projectUrl" value="<%=request.getRequestURL()%>" />
-<input type="hidden" name="searchServletUrl" value="<%=request.getAttribute("searchServletUrl")%>"/>
+<input type="hidden" name="projectUrl" value="<%=request.getHeader("referer")%>" />
<input type="submit" name="Save" /></form>
</center>
<p align="right">©2004-2009 CodeLutin</p>
Modified: trunk/src/main/webapp/Save.jsp
===================================================================
--- trunk/src/main/webapp/Save.jsp 2011-06-21 12:56:58 UTC (rev 130)
+++ trunk/src/main/webapp/Save.jsp 2011-06-22 12:46:07 UTC (rev 131)
@@ -10,7 +10,7 @@
<%if(result.equals("authError")) { %>
- <h4> Bad login or password, can't save modification </h4>
+ <h4> <font color="red"> Bad username or password, can't save modification</font> </h4>
<% } else if(result.equals("erreur")) { %>
<h4> Can't save modification </h4>
<% } else if(result.equals("uselessSave")) { %>
Added: trunk/src/main/webapp/Search.jsp
===================================================================
--- trunk/src/main/webapp/Search.jsp (rev 0)
+++ trunk/src/main/webapp/Search.jsp 2011-06-22 12:46:07 UTC (rev 131)
@@ -0,0 +1,27 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<%@page import="org.nuiton.scmwebeditor.actions.SearchAction"%>
+<%@page import="java.util.LinkedList" %>
+<%@page import="java.util.Iterator" %>
+ <%@ taglib prefix="s" uri="/struts-tags"%>
+ <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
+ <sj:head jquerytheme="default"/>
+
+<table>
+ <%
+ SearchAction action = SearchAction.getAction();
+
+ LinkedList<String> files = action.getFiles();
+
+ Iterator<String> it = files.iterator();
+
+ while(it.hasNext()) {
+ String file = it.next();
+ %>
+ <tr><td>
+ <a href="checkout.action?address=<%=file%>&projectUrl="<%=request.getRequestURL()%>" ><%=file%></a>
+
+ </td></tr>
+ <% } %>
+
+</table>
\ No newline at end of file
1
0
r130 - in trunk/src/main: java/org/nuiton/scmwebeditor/actions resources webapp
by kcardineaud@users.nuiton.org 21 Jun '11
by kcardineaud@users.nuiton.org 21 Jun '11
21 Jun '11
Author: kcardineaud
Date: 2011-06-21 14:56:58 +0200 (Tue, 21 Jun 2011)
New Revision: 130
Url: http://nuiton.org/repositories/revision/scmwebeditor/130
Log:
Add JQuery for ajax save and continue option
Added:
trunk/src/main/java/org/nuiton/scmwebeditor/actions/SaveAction.java
trunk/src/main/webapp/Save.jsp
Removed:
trunk/src/main/webapp/Preview.js
trunk/src/main/webapp/Saver.js
Modified:
trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/ModificationViewer.jsp
trunk/src/main/webapp/Preview.jsp
Added: trunk/src/main/java/org/nuiton/scmwebeditor/actions/SaveAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/SaveAction.java (rev 0)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/SaveAction.java 2011-06-21 12:56:58 UTC (rev 130)
@@ -0,0 +1,44 @@
+package org.nuiton.scmwebeditor.actions;
+
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
+
+public class SaveAction extends ScmWebEditorCommitAction {
+
+ String result;
+
+ public String getResult() {
+ return result;
+ }
+
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -115627369699637253L;
+
+
+ public String save() {
+
+ if(origText.equals(newText)) {
+ result = "uselessSave";
+ return Action.SUCCESS;
+ }
+
+ result = execute();
+
+ return Action.SUCCESS;
+ }
+
+ static public SaveAction getAction() {
+ return (SaveAction) ActionContext.getContext()
+ .get(CONTEXT_ACTION_KEY);
+ }
+
+
+}
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-21 09:02:44 UTC (rev 129)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-21 12:56:58 UTC (rev 130)
@@ -138,7 +138,7 @@
log.error("SVN FAIL",e);
}
//Suppression du repertoire temporaire
- delTempDirectory(svnSess);
+ //delTempDirectory(svnSess);
request.setAttribute(ATTRIBUTE_REDIRECT_URL, getRedirectUrl(svnSess));
return "erreur";
}
@@ -146,7 +146,7 @@
if (svnSess.getCheckoutdir() != null) {
//Suppression du repertoire temporaire
- delTempDirectory(svnSess);
+ //delTempDirectory(svnSess);
}
//if commit success user is redirect on the project page
request.setAttribute(ATTRIBUTE_REDIRECTION_URL, svnSess.getProjectUrl());
@@ -155,7 +155,7 @@
log.debug("End of commit");
}
//Suppression du repertoire temporaire
- delTempDirectory(svnSess);
+ //delTempDirectory(svnSess);
return "success";
}
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-06-21 09:02:44 UTC (rev 129)
+++ trunk/src/main/resources/struts.xml 2011-06-21 12:56:58 UTC (rev 130)
@@ -16,6 +16,9 @@
<result name="authError" >/ModificationViewer.jsp</result>
<result name="erreur">/BadFileRedirect.jsp</result>
</action>
+ <action name="save" class="org.nuiton.scmwebeditor.actions.SaveAction" method="save">
+ <result>/Save.jsp</result>
+ </action>
<action name="preview" class="org.nuiton.scmwebeditor.actions.PreviewAction" method="execute">
<result>/Preview.jsp</result>
</action>
Modified: trunk/src/main/webapp/ModificationViewer.jsp
===================================================================
--- trunk/src/main/webapp/ModificationViewer.jsp 2011-06-21 09:02:44 UTC (rev 129)
+++ trunk/src/main/webapp/ModificationViewer.jsp 2011-06-21 12:56:58 UTC (rev 130)
@@ -22,13 +22,14 @@
<form method="post" action=commit.action id="editForm">
<script src="GereFormSize.js" type="text/javascript"></script>
<textarea name="newText" id="newText"><%=request.getAttribute("OrigText")%></textarea>
- <script src="Preview.js" type="text/javascript"></script>
- <script src="Saver.js" type="text/javascript"></script>
<script src="GereSession.js" type="text/javascript"></script>
<script src="cancelRedirectDelete.js" type="text/javascript"></script>
<script src="pictureUpload.js" type="text/javascript"></script>
<noscript><h4>Javascript is not activated. You can't only use Save and Quit or Reset button.</h4></noscript>
<noscript><h4>For a better use of SCMWebEditor please activate JavaScript.</h4></noscript>
+
+ <div id="htmlcontentCommit"></div>
+
<p>Commit Message: <input type="text" name="commitMessage" title="Let a commit message with this file."/></p>
<%if (request.getAttribute("IsLogin").equals(false) == true){
@@ -52,15 +53,29 @@
<input type="hidden" name="origText" value="<%=request.getAttribute("OrigText")%>"/>
<input type="hidden" name="scmEditorUrl" value="<%=request.getAttribute("scmEditorUrl")%>"/>
<input type="hidden" name="previewServletUrl" value="<%=request.getAttribute("previewServletUrl")%>"/>
- <input title="Save your work and continue editing this file." type="button" value="Save and Continue Editing" name="SaveandC" onclick="javascript:saver(this.form.newText, this.form.username, this.form.pw, this.form.commitMessage, this.form.origText, this.form.scmEditorUrl);"/>
+
+ <s:url id="ajaxCommit" value="save.action" />
+
+ <sj:submit
+ id="ajaxSaveButton"
+ formIds="editForm"
+ targets="htmlcontentCommit"
+ href="%{ajaxCommit}"
+ indicator="indicator"
+ button="true"
+ buttonIcon="ui-icon-refresh"
+ value="Save and Continue Editing"
+ >
+ </sj:submit>
+
<input title="Save this file and go back to previous page." type="submit" value="Save and Quit" name="Save"/>
+
<%if (request.getAttribute("format")!=null && request.getAttribute("format")!=null && request.getAttribute("format").equals("rst") == true){
%>
-
- <s:url id="ajaxPreview" value="preview.action" />
+ <s:url id="ajaxPreview" value="preview.action" />
<sj:submit
- id="ajaxformlink"
+ id="ajaxPreviewButton"
formIds="editForm"
targets="htmlcontentPreview"
href="%{ajaxPreview}"
@@ -70,9 +85,9 @@
value="Preview"
>
</sj:submit>
+
+ <%}%>
-
- <%}%>
<input title="Reset text as current repository HEAD revision." type="reset" value="Reset" name="Reset" alt="Test plop plop plop"/>
<input type="hidden" value="<%=request.getAttribute("ProjectUrl")%>" name="ProjectUrl">
<input title="Exit ScmWebEditor without saving." type="button" value="Exit" name="Cancel" onclick="javascript:cancelRedirectDelete(this.form.origText, this.form.username, this.form.pw, this.form.commitMessage, this.form.ProjectUrl, this.form.scmEditorUrl);"/>
Deleted: trunk/src/main/webapp/Preview.js
===================================================================
--- trunk/src/main/webapp/Preview.js 2011-06-21 09:02:44 UTC (rev 129)
+++ trunk/src/main/webapp/Preview.js 2011-06-21 12:56:58 UTC (rev 130)
@@ -1,56 +0,0 @@
-/**
- * @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;
- document.getElementById("prevtitle").innerHTML = "Preview : ";
- document.getElementById("prev").innerHTML ="<div id=\"preview\" >"+response+"</div>";
- }
- else if (http.readyState == 4 && http.status == 406)
- {
- alert("Bad RestructuredText file format please correct it.");
- }
-}
-
-function preview(my_text, url)
-{
- sendRequest("POST", "preview.action", my_text);
-}
-
Modified: trunk/src/main/webapp/Preview.jsp
===================================================================
--- trunk/src/main/webapp/Preview.jsp 2011-06-21 09:02:44 UTC (rev 129)
+++ trunk/src/main/webapp/Preview.jsp 2011-06-21 12:56:58 UTC (rev 130)
@@ -2,7 +2,7 @@
import="org.nuiton.scmwebeditor.actions.PreviewAction"%>
<%--Title and div for rst preview--%>
- <h3 id="prevtitle" ></h3>
+ <h3 id="prevtitle" >Preview :</h3>
<div id="prev" title="Preview">
<div id="preview" >
<%
Added: trunk/src/main/webapp/Save.jsp
===================================================================
--- trunk/src/main/webapp/Save.jsp (rev 0)
+++ trunk/src/main/webapp/Save.jsp 2011-06-21 12:56:58 UTC (rev 130)
@@ -0,0 +1,22 @@
+<%@page
+ import="org.nuiton.scmwebeditor.actions.SaveAction"%>
+<%@page import="java.util.Date" %>
+ <%
+ SaveAction action = SaveAction.getAction();
+
+ String result = action.getResult();
+ %>
+
+
+
+ <%if(result.equals("authError")) { %>
+ <h4> Bad login or password, can't save modification </h4>
+ <% } else if(result.equals("erreur")) { %>
+ <h4> Can't save modification </h4>
+ <% } else if(result.equals("uselessSave")) { %>
+ <h4> It's useless to save the file, it is not modify</h4>
+ <% } else { %>
+ <h4>Last change save <%=new Date()%> </h4>
+ <% } %>
+
+
\ No newline at end of file
Deleted: trunk/src/main/webapp/Saver.js
===================================================================
--- trunk/src/main/webapp/Saver.js 2011-06-21 09:02:44 UTC (rev 129)
+++ trunk/src/main/webapp/Saver.js 2011-06-21 12:56:58 UTC (rev 130)
@@ -1,59 +0,0 @@
-/**
- * @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("newText="+text.value+"&username="+login.value+"&pw="+pass.value+"&commitMessage="+message.value+"&origText="+orig_text.value);
-}
-
-function handleResp()
-{
- if(http.readyState == 4 && http.status != 401){
- alert("Save Ok. Page will be reload shortly please wait.");
- 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, scmEditorUrl)
-{
-
- if (my_text.value != orig_text.value){
- if (confirm("Do you really want to save?")){
-
- sendReq("POST", "commit.action", my_text, login, pass, message, orig_text);
-
- }
- } else{
- alert("File don't need to be save.");
- }
-}
\ No newline at end of file
1
0
r129 - in trunk/src/main: java/org/nuiton/scmwebeditor java/org/nuiton/scmwebeditor/actions resources webapp
by kcardineaud@users.nuiton.org 21 Jun '11
by kcardineaud@users.nuiton.org 21 Jun '11
21 Jun '11
Author: kcardineaud
Date: 2011-06-21 11:02:44 +0200 (Tue, 21 Jun 2011)
New Revision: 129
Url: http://nuiton.org/repositories/revision/scmwebeditor/129
Log:
Add JQuery for ajax preview
Added:
trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java
trunk/src/main/webapp/Preview.jsp
Removed:
trunk/src/main/java/org/nuiton/scmwebeditor/AbstractScmWebEditor.java
Modified:
trunk/src/main/java/org/nuiton/scmwebeditor/PreviewServlet.java
trunk/src/main/java/org/nuiton/scmwebeditor/PrivateSvnServlet.java
trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java
trunk/src/main/java/org/nuiton/scmwebeditor/SvnSession.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java
trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/ModificationViewer.jsp
Deleted: trunk/src/main/java/org/nuiton/scmwebeditor/AbstractScmWebEditor.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/AbstractScmWebEditor.java 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/AbstractScmWebEditor.java 2011-06-21 09:02:44 UTC (rev 129)
@@ -1,221 +0,0 @@
-/*
- * #%L
- * Nuiton-ScmWebEditor
- *
- * $Id: AbstractScmWebEditorServlet.java 89 2010-04-21 12:12:20Z ymartel $
- * $HeadURL: http://svn.nuiton.org/svn/scmwebeditor/trunk/src/main/java/org/nuiton/scmwe… $
- * %%
- * Copyright (C) 2009 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.scmwebeditor;
-
-import info.monitorenter.cpdetector.io.*;
-
-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 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 java.io.*;
-import java.net.MalformedURLException;
-import java.nio.charset.Charset;
-
-/**
- * User: chemit
- * Date: 24 nov. 2009
- * Time: 21:24:39
- */
-public class AbstractScmWebEditor {
-
- private static final long serialVersionUID = 1L;
-
- private static final Log log = LogFactory.getLog(AbstractScmWebEditor.class);
-
- //TODO-TC200924 : uniformize all this different parameter and attribute, this is a bit messy...
- protected static final String PARAMETER_ADRESSE = "address";
- protected static final String PARAMETER_SCM_EDITOR_URL = "scmEditorUrl";
- protected static final String PARAMETER_PROJECT_URL = "projectUrl";
- protected static final String PARAMETER_FILE_NAME = "file_name";
- protected static final String PARAMETER_LANG = "lang";
- protected static final String PARAMETER_DEFAULT_LANG = "defaultLang";
- protected static final String PARAMETER_FORMAT = "format";
- protected static final String PARAMETER_USERNAME = "username";
- protected static final String PARAMETER_PW = "pw";
- protected static final String PARAMETER_MYTEXT = "Mytext";
- protected static final String PARAMETER_ORIG_TEXT = "Orig_text";
- protected static final String PARAMETER_COMMIT_MESSAGE = "Commit_message";
- protected static final String PARAMETER_TEXT = "text";
-
- //protected static final String ATTRIBUTE_TEMPDIR = "javax.servlet.context.tempdir";
- // protected static final String ATTRIBUTE_SVN_PATH_URL = "svnPath_url";
-// protected static final String ATTRIBUTE_FILE_NAME_URL = "fileName_url";
- protected static final String ATTRIBUTE_REDIRECTION_URL = "Redirection_url";
- // protected static final String ATTRIBUTE_LANG = "Lang";
- // protected static final String ATTRIBUTE_FORMAT = "Format";
- private static final String ATTRIBUTE_SVN_SESSION = "myInfo";
-
- protected static final String ATTRIBUTE_ORIG_TEXT = "OrigText";
- protected static final String ATTRIBUTE_INVALIDATE_MAX_TIME = "InvalidateMaxTime";
- protected static final String ATTRIBUTE_LOGIN = "Login";
- protected static final String ATTRIBUTE_IS_LOGIN = "IsLogin";
- protected static final String ATTRIBUTE_BAD_LOGIN = "badLogin";
- protected static final String ATTRIBUTE_PROJECT_URL = "Project_url";
- protected static final String ATTRIBUTE_SCM_EDITOR_URI = "scmEditorUri";
- protected static final String ATTRIBUTE_PREVIEW_SERVLET_URL = "previewServletUrl";
- protected static final String ATTRIBUTE_FILESEARCH_SERVLET_URL = "searchServletUrl";
- protected static final String ATTRIBUTE_REDIRECT_URL = "Redirect_url";
- protected static final String ATTRIBUTE_PRIVATE_SERVLET_URI = "privateServletUri";
-
- protected static CodepageDetectorProxy detector;
-
- protected 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
- */
- protected void convertToUnicode(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);
- }
- }
- }
- }
-
- public void delTempDirectory(SvnSession svnSess) {
- try {
- FileUtils.deleteDirectory(svnSess.getCheckoutdir());
- } catch (IOException e) {
- if(log.isErrorEnabled()) {
- log.error("Can't delete temp directory");
- }
- }
- }
-
-
- protected SvnSession getSvnSession(HttpSession httpSession) {
- SvnSession svnSess = (SvnSession) httpSession.getAttribute(ATTRIBUTE_SVN_SESSION);
- return svnSess;
- }
-
- protected void setSvnSession(HttpSession httpSession, SvnSession svnSess) {
- httpSession.setAttribute(ATTRIBUTE_SVN_SESSION, svnSess);
- }
-
- protected File getTempDir(HttpSession httpSession) {
- File tmp_dir = getSvnSession(httpSession).getCheckoutdir();
- return tmp_dir;
- }
-
-/*
- protected void redirect(HttpServletRequest request, HttpServletResponse response, String path) throws IOException, ServletException {
- RequestDispatcher requestDispacher = getServletContext().getRequestDispatcher(path);
- requestDispacher.forward(request, response);
- }
-*/
- protected String getRedirectUrl(SvnSession svnSess) {
- StringBuilder buffer = new StringBuilder();
- buffer.append(svnSess.getScmEditorUrl());
- buffer.append('?').append(PARAMETER_ADRESSE).append('=').append(svnSess.getSvnPath()+svnSess.getFileName());
- buffer.append("&").append(PARAMETER_PROJECT_URL).append('=').append(svnSess.getProjectUrl());
-
- String url = buffer.toString();
- return url;
- }
-
-}
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/PreviewServlet.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/PreviewServlet.java 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/PreviewServlet.java 2011-06-21 09:02:44 UTC (rev 129)
@@ -40,7 +40,7 @@
/**
* @author geoffroy lorieux
*/
-public class PreviewServlet extends AbstractScmWebEditor {
+public class PreviewServlet extends ScmWebEditorBaseAction {
private static final long serialVersionUID = 1L;
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/PrivateSvnServlet.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/PrivateSvnServlet.java 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/PrivateSvnServlet.java 2011-06-21 09:02:44 UTC (rev 129)
@@ -37,7 +37,7 @@
/**
* @author geoffroy lorieux
*/
-public class PrivateSvnServlet extends AbstractScmWebEditor {
+public class PrivateSvnServlet extends ScmWebEditorBaseAction {
private static final long serialVersionUID = 1L;
Added: trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java (rev 0)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/ScmWebEditorBaseAction.java 2011-06-21 09:02:44 UTC (rev 129)
@@ -0,0 +1,219 @@
+/*
+ * #%L
+ * Nuiton-ScmWebEditor
+ *
+ * $Id: AbstractScmWebEditorServlet.java 89 2010-04-21 12:12:20Z ymartel $
+ * $HeadURL: http://svn.nuiton.org/svn/scmwebeditor/trunk/src/main/java/org/nuiton/scmwe… $
+ * %%
+ * Copyright (C) 2009 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.scmwebeditor;
+
+import info.monitorenter.cpdetector.io.*;
+
+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 com.opensymphony.xwork2.ActionSupport;
+
+import javax.servlet.http.HttpSession;
+import java.io.*;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+
+/**
+ * User: chemit
+ * Date: 24 nov. 2009
+ * Time: 21:24:39
+ */
+public class ScmWebEditorBaseAction extends ActionSupport {
+
+ private static final long serialVersionUID = 1L;
+ final static protected String CONTEXT_ACTION_KEY = "action";
+
+ private static final Log log = LogFactory.getLog(ScmWebEditorBaseAction.class);
+
+ //TODO-TC200924 : uniformize all this different parameter and attribute, this is a bit messy...
+ protected static final String PARAMETER_ADRESSE = "address";
+ protected static final String PARAMETER_SCM_EDITOR_URL = "scmEditorUrl";
+ protected static final String PARAMETER_PROJECT_URL = "projectUrl";
+ protected static final String PARAMETER_FILE_NAME = "file_name";
+ protected static final String PARAMETER_LANG = "lang";
+ protected static final String PARAMETER_DEFAULT_LANG = "defaultLang";
+ protected static final String PARAMETER_FORMAT = "format";
+ protected static final String PARAMETER_USERNAME = "username";
+ protected static final String PARAMETER_PW = "pw";
+ protected static final String PARAMETER_MYTEXT = "Mytext";
+ protected static final String PARAMETER_ORIG_TEXT = "Orig_text";
+ protected static final String PARAMETER_COMMIT_MESSAGE = "Commit_message";
+ protected static final String PARAMETER_TEXT = "text";
+
+ //protected static final String ATTRIBUTE_TEMPDIR = "javax.servlet.context.tempdir";
+ // protected static final String ATTRIBUTE_SVN_PATH_URL = "svnPath_url";
+// protected static final String ATTRIBUTE_FILE_NAME_URL = "fileName_url";
+ protected static final String ATTRIBUTE_REDIRECTION_URL = "Redirection_url";
+ // protected static final String ATTRIBUTE_LANG = "Lang";
+ // protected static final String ATTRIBUTE_FORMAT = "Format";
+ private static final String ATTRIBUTE_SVN_SESSION = "myInfo";
+
+ protected static final String ATTRIBUTE_ORIG_TEXT = "OrigText";
+ protected static final String ATTRIBUTE_INVALIDATE_MAX_TIME = "InvalidateMaxTime";
+ protected static final String ATTRIBUTE_LOGIN = "Login";
+ protected static final String ATTRIBUTE_IS_LOGIN = "IsLogin";
+ protected static final String ATTRIBUTE_BAD_LOGIN = "badLogin";
+ protected static final String ATTRIBUTE_PROJECT_URL = "Project_url";
+ protected static final String ATTRIBUTE_SCM_EDITOR_URI = "scmEditorUri";
+ protected static final String ATTRIBUTE_PREVIEW_SERVLET_URL = "previewServletUrl";
+ protected static final String ATTRIBUTE_FILESEARCH_SERVLET_URL = "searchServletUrl";
+ protected static final String ATTRIBUTE_REDIRECT_URL = "Redirect_url";
+ protected static final String ATTRIBUTE_PRIVATE_SERVLET_URI = "privateServletUri";
+
+ protected static CodepageDetectorProxy detector;
+
+ protected 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
+ */
+ protected void convertToUnicode(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);
+ }
+ }
+ }
+ }
+
+ public void delTempDirectory(SvnSession svnSess) {
+ try {
+ FileUtils.deleteDirectory(svnSess.getCheckoutdir());
+ } catch (IOException e) {
+ if(log.isErrorEnabled()) {
+ log.error("Can't delete temp directory");
+ }
+ }
+ }
+
+
+ protected SvnSession getSvnSession(HttpSession httpSession) {
+ SvnSession svnSess = (SvnSession) httpSession.getAttribute(ATTRIBUTE_SVN_SESSION);
+ return svnSess;
+ }
+
+ protected void setSvnSession(HttpSession httpSession, SvnSession svnSess) {
+ httpSession.setAttribute(ATTRIBUTE_SVN_SESSION, svnSess);
+ }
+
+ protected File getTempDir(HttpSession httpSession) {
+ File tmp_dir = getSvnSession(httpSession).getCheckoutdir();
+ return tmp_dir;
+ }
+
+/*
+ protected void redirect(HttpServletRequest request, HttpServletResponse response, String path) throws IOException, ServletException {
+ RequestDispatcher requestDispacher = getServletContext().getRequestDispatcher(path);
+ requestDispacher.forward(request, response);
+ }
+*/
+ protected String getRedirectUrl(SvnSession svnSess) {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(svnSess.getScmEditorUrl());
+ buffer.append('?').append(PARAMETER_ADRESSE).append('=').append(svnSess.getSvnPath()+svnSess.getFileName());
+ buffer.append("&").append(PARAMETER_PROJECT_URL).append('=').append(svnSess.getProjectUrl());
+
+ String url = buffer.toString();
+ return url;
+ }
+
+}
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/SearchServlet.java 2011-06-21 09:02:44 UTC (rev 129)
@@ -43,8 +43,12 @@
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNWCUtil;
-public class SearchServlet extends AbstractScmWebEditor {
+public class SearchServlet extends ScmWebEditorBaseAction {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8229295563440910960L;
private static final Log log = LogFactory.getLog(SearchServlet.class);
/**
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/SvnSession.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/SvnSession.java 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/SvnSession.java 2011-06-21 09:02:44 UTC (rev 129)
@@ -27,7 +27,6 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.scmwebeditor.actions.ScmWebEditorMainAction;
import org.nuiton.util.FileUtil;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNProperty;
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/PreviewAction.java 2011-06-21 09:02:44 UTC (rev 129)
@@ -1,9 +1,8 @@
package org.nuiton.scmwebeditor.actions;
-import java.io.ByteArrayInputStream;
+
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
@@ -14,17 +13,42 @@
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.nuiton.jrst.JRST;
-import org.nuiton.scmwebeditor.AbstractScmWebEditor;
+import org.nuiton.scmwebeditor.ScmWebEditorBaseAction;
import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
-public class PreviewAction extends AbstractScmWebEditor implements ServletRequestAware {
+public class PreviewAction extends ScmWebEditorBaseAction implements ServletRequestAware {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2388759298175611718L;
HttpServletRequest request;
- InputStream XMLResponse;
+ String XMLResponse;
+ String newText;
+
+
+ public String getNewText() {
+ return newText;
+ }
+
+ public void setNewText(String newText) {
+ this.newText = newText;
+ }
+
+ public String getXMLResponse() {
+ return XMLResponse;
+ }
+
+ public void setXMLResponse(String XMLResponse) {
+ this.XMLResponse = XMLResponse;
+ }
+
+
private static final Log log = LogFactory.getLog(PreviewAction.class);
public String execute() {
@@ -35,13 +59,13 @@
public void setResponse() {
if(log.isDebugEnabled()) {
- log.debug("Enter in Servlet Action");
+ log.debug("Enter in preview action");
}
HttpSession httpSession = request.getSession(true);
File tmpDir = getTempDir(httpSession);
//Text recuperation
- String myData = request.getParameter(PARAMETER_TEXT);
+ String myData = newText;
//Text formating and tempfile creating
String myDataWithoutcrlf = myData.replace("\r", "");
File fileInDirCopy = new File(tmpDir, "copy" + httpSession.getId() + ".rst");
@@ -52,7 +76,7 @@
FileUtils.writeStringToFile(fileInDirCopy, myDataWithoutcrlf);
} catch (IOException e) {
if(log.isErrorEnabled()) {
- log.error("Erreur de lecture/ecriture",e);
+ log.error("read/write error",e);
}
}
@@ -70,14 +94,14 @@
if(log.isWarnEnabled()) {
log.warn("RST generate fail",eee);
}
- XMLResponse = new ByteArrayInputStream("<h4>Parsing error, please read RST specification<h4>".getBytes());
+ XMLResponse = "<h4>Parsing error, please read RST specification<h4>";
return;
}
copy.delete();
try {
- XMLResponse = new ByteArrayInputStream(FileUtils.readFileToString(httpFile).getBytes());
+ XMLResponse = FileUtils.readFileToString(httpFile);
} catch (IOException e) {
e.printStackTrace();
}
@@ -88,14 +112,11 @@
}
- public InputStream getXMLResponse() {
- return XMLResponse;
+ static public PreviewAction getAction() {
+ return (PreviewAction) ActionContext.getContext()
+ .get(CONTEXT_ACTION_KEY);
}
- public void setXMLResponse(InputStream xMLResponse) {
- XMLResponse = xMLResponse;
- }
-
@Override
public void setServletRequest(HttpServletRequest request) {
this.request = request;
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-21 09:02:44 UTC (rev 129)
@@ -11,14 +11,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ServletRequestAware;
-import org.nuiton.scmwebeditor.AbstractScmWebEditor;
+import org.nuiton.scmwebeditor.ScmWebEditorBaseAction;
import org.nuiton.scmwebeditor.SvnSession;
import org.tmatesoft.svn.core.SVNAuthenticationException;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.wc.SVNCommitClient;
-public class ScmWebEditorCommitAction extends AbstractScmWebEditor implements ServletRequestAware {
+public class ScmWebEditorCommitAction extends ScmWebEditorBaseAction implements ServletRequestAware {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6374273568146287730L;
+
private static final Log log = LogFactory.getLog(ScmWebEditorCommitAction.class);
protected String newText;
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-21 09:02:44 UTC (rev 129)
@@ -6,14 +6,13 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-import javax.swing.Action;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ServletRequestAware;
-import org.nuiton.scmwebeditor.AbstractScmWebEditor;
+import org.nuiton.scmwebeditor.ScmWebEditorBaseAction;
import org.nuiton.scmwebeditor.SvnSession;
import org.tmatesoft.svn.core.SVNAuthenticationException;
import org.tmatesoft.svn.core.SVNDepth;
@@ -22,8 +21,13 @@
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;
-public class ScmWebEditorMainAction extends AbstractScmWebEditor implements ServletRequestAware {
+public class ScmWebEditorMainAction extends ScmWebEditorBaseAction implements ServletRequestAware {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8361035067228171624L;
+
private static final Log log = LogFactory.getLog(ScmWebEditorMainAction.class);
protected String address;
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/resources/struts.xml 2011-06-21 09:02:44 UTC (rev 129)
@@ -17,10 +17,7 @@
<result name="erreur">/BadFileRedirect.jsp</result>
</action>
<action name="preview" class="org.nuiton.scmwebeditor.actions.PreviewAction" method="execute">
- <result type="stream" >
- <param name="contentType">text/xml</param>
- <param name="inputName">XMLResponse</param>
- </result>
+ <result>/Preview.jsp</result>
</action>
<action name="search" class="org.nuiton.scmwebeditor.actions.SearchAction" method="execute">
<result type="stream" >
Modified: trunk/src/main/webapp/ModificationViewer.jsp
===================================================================
--- trunk/src/main/webapp/ModificationViewer.jsp 2011-06-20 15:03:57 UTC (rev 128)
+++ trunk/src/main/webapp/ModificationViewer.jsp 2011-06-21 09:02:44 UTC (rev 129)
@@ -1,5 +1,8 @@
<%-- Document : ModificationViewer Created on : 10 sept. 2009, 13:43:11 Author : glorieux --%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
+ <%@ taglib prefix="s" uri="/struts-tags"%>
+ <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
+ <sj:head jquerytheme="default"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
@@ -16,7 +19,7 @@
<%if (request.getAttribute("format")!=null && request.getAttribute("format").equals("rst") == true){
%><h4>For any Problem with RestruturedText visit <a href="http://docutils.sourceforge.net/rst.html">RST documentation website</a>.</h4></center><%}%>
<center>
- <form method="post" action=commit.action>
+ <form method="post" action=commit.action id="editForm">
<script src="GereFormSize.js" type="text/javascript"></script>
<textarea name="newText" id="newText"><%=request.getAttribute("OrigText")%></textarea>
<script src="Preview.js" type="text/javascript"></script>
@@ -31,11 +34,11 @@
<%if (request.getAttribute("IsLogin").equals(false) == true){
%>
<%if (request.getAttribute("badLogin")!=null && request.getAttribute("badLogin").equals(true)) { %>
- <p>
- <font color="red">
- Bad username or password
- </font>
- </p>
+ <p>
+ <font color="red">
+ Bad username or password
+ </font>
+ </p>
<% } %>
<p>
@@ -52,14 +55,41 @@
<input title="Save your work and continue editing this file." type="button" value="Save and Continue Editing" name="SaveandC" onclick="javascript:saver(this.form.newText, this.form.username, this.form.pw, this.form.commitMessage, this.form.origText, this.form.scmEditorUrl);"/>
<input title="Save this file and go back to previous page." type="submit" value="Save and Quit" name="Save"/>
<%if (request.getAttribute("format")!=null && request.getAttribute("format")!=null && request.getAttribute("format").equals("rst") == true){
- %><input title="html preview of the current rst file state." type="button" value="Preview" name="Preview" onclick="javascript:preview(this.form.newText, this.form.previewServletUrl);"/><%}%>
+ %>
+
+ <s:url id="ajaxPreview" value="preview.action" />
+
+ <sj:submit
+ id="ajaxformlink"
+ formIds="editForm"
+ targets="htmlcontentPreview"
+ href="%{ajaxPreview}"
+ indicator="indicator"
+ button="true"
+ buttonIcon="ui-icon-refresh"
+ value="Preview"
+ >
+ </sj:submit>
+
+
+ <%}%>
<input title="Reset text as current repository HEAD revision." type="reset" value="Reset" name="Reset" alt="Test plop plop plop"/>
<input type="hidden" value="<%=request.getAttribute("ProjectUrl")%>" name="ProjectUrl">
<input title="Exit ScmWebEditor without saving." type="button" value="Exit" name="Cancel" onclick="javascript:cancelRedirectDelete(this.form.origText, this.form.username, this.form.pw, this.form.commitMessage, this.form.ProjectUrl, this.form.scmEditorUrl);"/>
- </form></center>
- <%--Title and div for rst preview--%>
- <h3 id="prevtitle" ></h3>
- <div id="prev" title="Preview"></div>
+
+
+
+
+
+ </form>
+
+
+
+
+
+ </center>
+ <div id="htmlcontentPreview"></div>
+
<p align="right">©2004-2009 CodeLutin</p>
</body>
</html>
Added: trunk/src/main/webapp/Preview.jsp
===================================================================
--- trunk/src/main/webapp/Preview.jsp (rev 0)
+++ trunk/src/main/webapp/Preview.jsp 2011-06-21 09:02:44 UTC (rev 129)
@@ -0,0 +1,17 @@
+<%@page
+ import="org.nuiton.scmwebeditor.actions.PreviewAction"%>
+
+ <%--Title and div for rst preview--%>
+ <h3 id="prevtitle" ></h3>
+ <div id="prev" title="Preview">
+ <div id="preview" >
+ <%
+ PreviewAction action = PreviewAction.getAction();
+
+ String preview = action.getXMLResponse();
+
+ %>
+ <%=preview%>
+
+ </div>
+ </div>
1
0
r128 - in trunk/src/main: java/org/nuiton/scmwebeditor resources webapp
by kcardineaud@users.nuiton.org 20 Jun '11
by kcardineaud@users.nuiton.org 20 Jun '11
20 Jun '11
Author: kcardineaud
Date: 2011-06-20 17:03:57 +0200 (Mon, 20 Jun 2011)
New Revision: 128
Url: http://nuiton.org/repositories/revision/scmwebeditor/128
Log:
Add search file option (but isn't finish)
Modified:
trunk/src/main/java/org/nuiton/scmwebeditor/PrivateSvnServlet.java
trunk/src/main/resources/struts.xml
trunk/src/main/webapp/OutConnection.jsp
trunk/src/main/webapp/PrivateSvnRedirect.jsp
trunk/src/main/webapp/fileSearch.js
Modified: trunk/src/main/java/org/nuiton/scmwebeditor/PrivateSvnServlet.java
===================================================================
--- trunk/src/main/java/org/nuiton/scmwebeditor/PrivateSvnServlet.java 2011-06-20 12:41:21 UTC (rev 127)
+++ trunk/src/main/java/org/nuiton/scmwebeditor/PrivateSvnServlet.java 2011-06-20 15:03:57 UTC (rev 128)
@@ -58,7 +58,7 @@
svnSess.updateAuthentication(request.getParameter(PARAMETER_USERNAME), request.getParameter(PARAMETER_PW));
//FIXME-TC20091124 : why repush the object already in session, I don't see the point...
setSvnSession(httpSession, svnSess);
-// Recalling helloservlet with user information stock on session
+ // Recalling helloservlet with user information stock on session
String url = getRedirectUrl(svnSess);
if (log.isDebugEnabled()) {
log.debug("redirect url = " + url);
Modified: trunk/src/main/resources/struts.xml
===================================================================
--- trunk/src/main/resources/struts.xml 2011-06-20 12:41:21 UTC (rev 127)
+++ trunk/src/main/resources/struts.xml 2011-06-20 15:03:57 UTC (rev 128)
@@ -22,5 +22,11 @@
<param name="inputName">XMLResponse</param>
</result>
</action>
+ <action name="search" class="org.nuiton.scmwebeditor.actions.SearchAction" method="execute">
+ <result type="stream" >
+ <param name="contentType">text/xml</param>
+ <param name="inputName">XMLResponse</param>
+ </result>
+ </action>
</package>
</struts>
\ No newline at end of file
Modified: trunk/src/main/webapp/OutConnection.jsp
===================================================================
--- trunk/src/main/webapp/OutConnection.jsp 2011-06-20 12:41:21 UTC (rev 127)
+++ trunk/src/main/webapp/OutConnection.jsp 2011-06-20 15:03:57 UTC (rev 128)
@@ -22,7 +22,7 @@
</center>
<center>
<form method="get" action="checkout.action">
- <p><label>SCM path: <input TYPE=text name="address" SIZE=100></label><input disabled="disabled" type="button" value="Search Files" name="search" onclick="javascript:fileSearch(this.form.address, 'SearchServlet');"/></p>
+ <p><label>SCM path: <input TYPE=text name="address" SIZE=100></label><input type="button" value="Search Files" name="search" onclick="javascript:fileSearch(this.form.address);"/></p>
<input type="hidden" name="projectUrl" value="<%=request.getRequestURL()%>" />
Modified: trunk/src/main/webapp/PrivateSvnRedirect.jsp
===================================================================
--- trunk/src/main/webapp/PrivateSvnRedirect.jsp 2011-06-20 12:41:21 UTC (rev 127)
+++ trunk/src/main/webapp/PrivateSvnRedirect.jsp 2011-06-20 15:03:57 UTC (rev 128)
@@ -13,7 +13,7 @@
</head>
<body>
<a target="_blank" href="http://maven-site.nuiton.org/scmwebeditor/"><img src="img/ScmWebEditor_main.png" alt="$alt" /></a>
-<form method="post" action=<%=request.getAttribute("privateServletUri")%>>
+<form method="post" action="checkout.action" >
<script src="cancelRedirect.js"></script>
<p>You try to access a Private SCM. Please login</p>
<p><label ACCESSKEY=U>User name: <input TYPE=text
Modified: trunk/src/main/webapp/fileSearch.js
===================================================================
--- trunk/src/main/webapp/fileSearch.js 2011-06-20 12:41:21 UTC (rev 127)
+++ trunk/src/main/webapp/fileSearch.js 2011-06-20 15:03:57 UTC (rev 128)
@@ -22,26 +22,29 @@
//Make the XMLHttpRequest Object
var http= createRequestObject();
-function sendRequestToFileSearchServlet(scmPath, scmEditorUrl)
+function sendRequestToFileSearchAction(scmPath, searchUrl)
{
- http.open("POST", scmEditorUrl, true);
- http.onreadystatechange = handleResponseFromFileSearchServlet;
+ http.open("POST", searchUrl, true);
+ http.onreadystatechange = handleResponseFromFileSearchAction;
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- http.send("adresse="+scmPath.value);
+ http.send("address="+scmPath.value);
}
-function handleResponseFromFileSearchServlet()
+function handleResponseFromFileSearchAction()
{
if(http.readyState == 4 && http.status != 401){
alert("Can find file Continue");
+ var response = http.responseText;
+ alert(response);
+
+
} else if (http.readyState == 4 && http.status == 401){
alert("Cannot find files please recheck Scm path.");
}
}
-function fileSearch(scmPath, scmEditorUrl)
+function fileSearch(scmPath)
{
alert(scmPath.value);
- alert(scmEditorUrl);
- sendRequestToFileSearchServlet(scmPath, scmEditorUrl);
+ sendRequestToFileSearchAction(scmPath, "search.action");
}
1
0
Author: kcardineaud
Date: 2011-06-20 14:41:21 +0200 (Mon, 20 Jun 2011)
New Revision: 127
Url: http://nuiton.org/repositories/revision/scmwebeditor/127
Log:
Add save and continue option
Modified:
trunk/src/main/webapp/ModificationViewer.jsp
trunk/src/main/webapp/Preview.js
trunk/src/main/webapp/Saver.js
trunk/src/main/webapp/css/main.css
Modified: trunk/src/main/webapp/ModificationViewer.jsp
===================================================================
--- trunk/src/main/webapp/ModificationViewer.jsp 2011-06-20 09:40:04 UTC (rev 126)
+++ trunk/src/main/webapp/ModificationViewer.jsp 2011-06-20 12:41:21 UTC (rev 127)
@@ -46,7 +46,7 @@
<input type="hidden" NAME=username />
<input type="hidden" NAME=pw /><%
}%>
- <input type="hidden" name="origText" value=<%=request.getAttribute("OrigText")%>/>
+ <input type="hidden" name="origText" value="<%=request.getAttribute("OrigText")%>"/>
<input type="hidden" name="scmEditorUrl" value="<%=request.getAttribute("scmEditorUrl")%>"/>
<input type="hidden" name="previewServletUrl" value="<%=request.getAttribute("previewServletUrl")%>"/>
<input title="Save your work and continue editing this file." type="button" value="Save and Continue Editing" name="SaveandC" onclick="javascript:saver(this.form.newText, this.form.username, this.form.pw, this.form.commitMessage, this.form.origText, this.form.scmEditorUrl);"/>
Modified: trunk/src/main/webapp/Preview.js
===================================================================
--- trunk/src/main/webapp/Preview.js 2011-06-20 09:40:04 UTC (rev 126)
+++ trunk/src/main/webapp/Preview.js 2011-06-20 12:41:21 UTC (rev 127)
@@ -41,7 +41,7 @@
{
var response = http.responseText;
document.getElementById("prevtitle").innerHTML = "Preview : ";
- document.getElementById("prev").innerHTML ="<div id=\"preview\" "+response+"</div>";
+ document.getElementById("prev").innerHTML ="<div id=\"preview\" >"+response+"</div>";
}
else if (http.readyState == 4 && http.status == 406)
{
Modified: trunk/src/main/webapp/Saver.js
===================================================================
--- trunk/src/main/webapp/Saver.js 2011-06-20 09:40:04 UTC (rev 126)
+++ trunk/src/main/webapp/Saver.js 2011-06-20 12:41:21 UTC (rev 127)
@@ -28,10 +28,10 @@
function sendReq(method, url, text, login, pass, message, orig_text)
{
- http.open(method, url.value, true);
+ 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);
+ http.send("newText="+text.value+"&username="+login.value+"&pw="+pass.value+"&commitMessage="+message.value+"&origText="+orig_text.value);
}
function handleResp()
@@ -46,14 +46,12 @@
function saver(my_text, login, pass, message, orig_text, scmEditorUrl)
{
+
if (my_text.value != orig_text.value){
if (confirm("Do you really want to save?")){
- if (message.value == ""){
- alert("You must enter a Commit message!!!", "");
- }
- else {
- sendReq("POST", scmEditorUrl, my_text, login, pass, message, orig_text);
- }
+
+ sendReq("POST", "commit.action", my_text, login, pass, message, orig_text);
+
}
} else{
alert("File don't need to be save.");
Modified: trunk/src/main/webapp/css/main.css
===================================================================
--- trunk/src/main/webapp/css/main.css 2011-06-20 09:40:04 UTC (rev 126)
+++ trunk/src/main/webapp/css/main.css 2011-06-20 12:41:21 UTC (rev 127)
@@ -12,7 +12,7 @@
}
#prevtitle {
- margin-left:12%;
+ margin-left:13%;
}
#preview {
1
0