r124 - in trunk/src/main: java/org/nuiton/scmwebeditor java/org/nuiton/scmwebeditor/actions resources webapp
Author: kcardineaud Date: 2011-06-17 16:43:57 +0200 (Fri, 17 Jun 2011) New Revision: 124 Url: http://nuiton.org/repositories/revision/scmwebeditor/124 Log: Modify the login system for commit a file Modified: trunk/src/main/java/org/nuiton/scmwebeditor/AbstractScmWebEditor.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 Modified: trunk/src/main/java/org/nuiton/scmwebeditor/AbstractScmWebEditor.java =================================================================== --- trunk/src/main/java/org/nuiton/scmwebeditor/AbstractScmWebEditor.java 2011-06-17 12:56:21 UTC (rev 123) +++ trunk/src/main/java/org/nuiton/scmwebeditor/AbstractScmWebEditor.java 2011-06-17 14:43:57 UTC (rev 124) @@ -51,9 +51,9 @@ 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 = "adresse"; + protected static final String PARAMETER_ADRESSE = "address"; protected static final String PARAMETER_SCM_EDITOR_URL = "scmEditorUrl"; - protected static final String PARAMETER_PROJECT_URL = "project_url"; + 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"; @@ -197,8 +197,7 @@ protected String getRedirectUrl(SvnSession svnSess) { StringBuilder buffer = new StringBuilder(); buffer.append(svnSess.getScmEditorUrl()); - buffer.append('?').append(PARAMETER_ADRESSE).append('=').append(svnSess.getSvnPath()); - buffer.append("&").append(PARAMETER_FILE_NAME).append('=').append(svnSess.getFileName()); + 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(); Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java =================================================================== --- trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-17 12:56:21 UTC (rev 123) +++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorCommitAction.java 2011-06-17 14:43:57 UTC (rev 124) @@ -113,9 +113,22 @@ 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(ATTRIBUTE_REDIRECT_URL, getRedirectUrl(svnSess)); - return "ko"; + log.debug("AUTH REDIRECT"+getRedirectUrl(svnSess)); + 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("badLogin", true); + return "authError"; } catch (SVNException e) { if(log.isErrorEnabled()) { log.error("SVN FAIL",e); @@ -126,7 +139,9 @@ } if (svnSess.getCheckoutdir() != null) { - log.debug("Delete tempdir"); + if(log.isDebugEnabled()) { + log.debug("Delete tempdir"); + } try { FileUtils.deleteDirectory(svnSess.getCheckoutdir()); } catch (IOException e) { @@ -141,7 +156,7 @@ if(log.isDebugEnabled()) { log.debug("End of commit"); } - return "ok"; + 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-17 12:56:21 UTC (rev 123) +++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/ScmWebEditorMainAction.java 2011-06-17 14:43:57 UTC (rev 124) @@ -107,7 +107,7 @@ tmp_log = svnSess.getLogin(); tmp_pass = svnSess.getPassword(); } - + svnSess = new SvnSession( relativePath, scmFileName, Modified: trunk/src/main/resources/struts.xml =================================================================== --- trunk/src/main/resources/struts.xml 2011-06-17 12:56:21 UTC (rev 123) +++ trunk/src/main/resources/struts.xml 2011-06-17 14:43:57 UTC (rev 124) @@ -12,7 +12,8 @@ <result name="editPage" >/ModificationViewer.jsp</result> </action> <action name="commit" class="org.nuiton.scmwebeditor.actions.ScmWebEditorCommitAction" method="execute"> - <result name="ok" >/accueil.jsp</result> + <result name="success" >/Redirect.jsp</result> + <result name="authError" >/ModificationViewer.jsp</result> <result name="ko">/BadFileRedirect.jsp</result> </action> </package> Modified: trunk/src/main/webapp/ModificationViewer.jsp =================================================================== --- trunk/src/main/webapp/ModificationViewer.jsp 2011-06-17 12:56:21 UTC (rev 123) +++ trunk/src/main/webapp/ModificationViewer.jsp 2011-06-17 14:43:57 UTC (rev 124) @@ -13,7 +13,7 @@ <body onload="cleanForm();geresession(<%=request.getAttribute("InvalidateMaxTime")%>, 5);"> <a title="ScmWebEditor Project Website" target="_blank" href="http://maven-site.nuiton.org/scmwebeditor/"><img src="img/ScmWebEditor_main.png" alt="ScmWebEditor logo"/></a> <center><h2>Welcome on SCMWebEditor</h2> - <%if (request.getAttribute("format").equals("rst") == true){ + <%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> @@ -29,7 +29,17 @@ <p>Commit Message: <input type="text" name="commitMessage" title="Let a commit message with this file."/></p> <%if (request.getAttribute("IsLogin").equals(false) == true){ - %><p><label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12 title="Commit Username."/></label> + %> + <%if (request.getAttribute("badLogin")!=null && request.getAttribute("badLogin").equals(true)) { %> + <p> + <font color="red"> + Bad username or password + </font> + </p> + <% } %> + <p> + + <label ACCESSKEY=U>User name: <input TYPE=text NAME=username SIZE=12 title="Commit Username."/></label> <label ACCESSKEY=P>Password: <input TYPE=password NAME=pw SIZE=12 title="Commit Password."/></label> </p><% } else { %><p>You are log as: <%=request.getAttribute("Login")%></p> @@ -41,7 +51,7 @@ <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.Orig_text, 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").equals("rst") == true){ + <%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);"/><%}%> <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("Project_url")%>" name="Project_url">
participants (1)
-
kcardineaud@users.nuiton.org