r213 - in trunk/src/main: java/org/nuiton/scmwebeditor java/org/nuiton/scmwebeditor/actions webapp/WEB-INF/content
Author: kcardineaud Date: 2011-08-12 15:25:23 +0200 (Fri, 12 Aug 2011) New Revision: 213 Url: http://nuiton.org/repositories/revision/scmwebeditor/213 Log: Change upload system to a better one that use jquery tree Modified: trunk/src/main/java/org/nuiton/scmwebeditor/SvnConnection.java trunk/src/main/java/org/nuiton/scmwebeditor/actions/UploadAction.java trunk/src/main/webapp/WEB-INF/content/uploadForm.jsp Modified: trunk/src/main/java/org/nuiton/scmwebeditor/SvnConnection.java =================================================================== --- trunk/src/main/java/org/nuiton/scmwebeditor/SvnConnection.java 2011-08-12 08:50:11 UTC (rev 212) +++ trunk/src/main/java/org/nuiton/scmwebeditor/SvnConnection.java 2011-08-12 13:25:23 UTC (rev 213) @@ -110,6 +110,10 @@ setManager(SVNClientManager.newInstance(getSvnOption(), getAuthManager())); } + /** + * + * @return + */ public String getUUID() { String repositoryUUID = null; try { @@ -128,6 +132,29 @@ return repositoryUUID; } + + /** + * + * @return + */ + public String getSvnRoot() { + String repositoryRoot = null; + try { + SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(addressSvn)); + ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(); + repository.setAuthenticationManager(authManager); + + repositoryRoot = repository.getRepositoryRoot(true).toString(); + } + catch (SVNException e) { + if(log.isDebugEnabled()) { + log.debug("Can't get SvnRoot"); + } + return null; + } + + return repositoryRoot; + } public ISVNAuthenticationManager getAuthManager() { return authManager; Modified: trunk/src/main/java/org/nuiton/scmwebeditor/actions/UploadAction.java =================================================================== --- trunk/src/main/java/org/nuiton/scmwebeditor/actions/UploadAction.java 2011-08-12 08:50:11 UTC (rev 212) +++ trunk/src/main/java/org/nuiton/scmwebeditor/actions/UploadAction.java 2011-08-12 13:25:23 UTC (rev 213) @@ -12,10 +12,10 @@ import org.apache.struts2.interceptor.ServletRequestAware; import org.nuiton.scmwebeditor.ScmWebEditorBaseAction; import org.nuiton.scmwebeditor.SvnConnection; -import org.nuiton.util.FileUtil; import org.tmatesoft.svn.core.SVNAuthenticationException; import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNUpdateClient; @@ -36,6 +36,8 @@ protected String pw; protected String svnPath; protected String address; + protected String svnRoot; + protected String fileRoot; protected boolean badLogin; protected boolean error; @@ -83,6 +85,10 @@ public void setAddress(String address) { this.address = address; } + + public String getAddress() { + return this.address; + } public boolean isBadLogin() { return badLogin; @@ -90,9 +96,28 @@ public boolean isError() { return error; } - + + public String getSvnRoot() { + return svnRoot; + } + + public String getFileRoot() { + return fileRoot; + } + + public String execute() { + SvnConnection svnConnection = new SvnConnection(address); + svnRoot = svnConnection.getSvnRoot(); + + fileRoot = svnConnection.getSvnPath(); + + if(svnRoot==null) { + svnRoot=fileRoot; + } + + if(upload==null) { return "redirect"; } @@ -155,8 +180,8 @@ File checkoutDir = null; try { - checkoutDir = FileUtil.createTempDirectory("scm_", ""); svnConn.createCheckoutdir(); + checkoutDir = svnConn.getCheckoutdir(); } catch (IOException e1) { if(log.isErrorEnabled()) { log.error("Can't create checkoutDir",e1); @@ -171,9 +196,9 @@ try { if (log.isDebugEnabled()) { - log.debug("Do Checkout of " + svnConn.getRemoteUrl()); + log.debug("Do Checkout of " + svnPath); } - upclient.doCheckout(svnConn.getRemoteUrl(), checkoutDir, + upclient.doCheckout(SVNURL.parseURIEncoded(svnPath), checkoutDir, SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, false); } catch (SVNAuthenticationException authexep) { @@ -211,7 +236,8 @@ //Copy file in checkourdir String checkoutPath = checkoutDir.getAbsolutePath(); - File file = new File(checkoutPath+svnPath,uploadFileName); +// File file = new File(checkoutPath+svnPath,uploadFileName); + File file = new File(checkoutPath,uploadFileName); try { FileUtils.copyFile(upload, file); @@ -234,7 +260,7 @@ try { if(log.isDebugEnabled()) { - log.debug("leSvnPath : "+checkoutPath+svnPath+uploadFileName); + log.debug("leSvnPath : "+checkoutPath+uploadFileName); } //On ajoute le repertoire Modified: trunk/src/main/webapp/WEB-INF/content/uploadForm.jsp =================================================================== --- trunk/src/main/webapp/WEB-INF/content/uploadForm.jsp 2011-08-12 08:50:11 UTC (rev 212) +++ trunk/src/main/webapp/WEB-INF/content/uploadForm.jsp 2011-08-12 13:25:23 UTC (rev 213) @@ -1,19 +1,55 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="org.nuiton.scmwebeditor.ScmSession"%> + <%@page import="org.nuiton.scmwebeditor.SvnConnection"%> + <%@ taglib prefix="s" uri="/struts-tags"%> + <%@ taglib prefix="sj" uri="/struts-jquery-tags"%> + <%@ taglib prefix="sjt" uri="/struts-jquery-tree-tags" %> + <!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> +<link rel="stylesheet" type="text/css" href="css/main.css"> </head> <body> +<sj:head debug="true" jquerytheme="default"/> + +<script> +$.subscribe('treeClicked', function(event, data) { + var item = event.originalEvent.data.rslt.obj; + + if(item.text().indexOf("/") != -1) { + window.document.getElementById("svnPath").value=item.attr("id"); + } + +}); + +</script> + + + <form method="POST" id="uploadForm" action="doUpload.action" enctype="multipart/form-data"> <label><s:text name="scm.uploadFile" /> : <input type="file" name="upload"/></label><br/> - <label><s:text name="scm.uploadPath" /> : <input type="text" name="svnPath" /></label><br/> + <label><s:text name="scm.uploadPath" /> : <s:textfield size="50px" type="text" name="svnPath" id="svnPath" value="%{fileRoot}" /></label><br/> + + <div id="searchTree"> + + <s:url id="searchTreeUrl" action="search?address=%{svnRoot}" /> + <sjt:tree id="svnTree" + htmlTitles="true" + jstreetheme="classic" + href="%{searchTreeUrl}" + onClickTopics="treeClicked" + /> + + </div> + + <% Object obj = session.getAttribute("ScmSession"); String usernameSvn = null;
participants (1)
-
kcardineaud@users.nuiton.org