branch develop updated (2752239 -> babafe3)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git from 2752239 Change the favicon new babafe3 Make the SvnConnection's code shorter and easier to understand The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit babafe3ef1fee639c62605524cec1a9170199ba9 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Fri May 22 16:47:08 2015 +0200 Make the SvnConnection's code shorter and easier to understand Summary of changes: .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 273 ++------------------- 1 file changed, 24 insertions(+), 249 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit babafe3ef1fee639c62605524cec1a9170199ba9 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Fri May 22 16:47:08 2015 +0200 Make the SvnConnection's code shorter and easier to understand --- .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 273 ++------------------- 1 file changed, 24 insertions(+), 249 deletions(-) diff --git a/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java b/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java index 7111d63..7aec0aa 100644 --- a/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java +++ b/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java @@ -469,144 +469,29 @@ public class SvnConnection implements ScmConnection { log.debug("ContentType : " + dto.getUploadContentType()); } - /* - * Checkout process - */ - SVNUpdateClient upclient = new SVNUpdateClient(manager, svnOption); - - checkoutdir = null; - try { - createCheckoutdir(); - } catch (IOException e1) { - if (log.isErrorEnabled()) { - log.error("Can't create checkoutDir", e1); - } - - resultDto.setError(UploadResultDto.ERROR); - return resultDto; - } - - String svnRoot = getSvnRoot(dto.getUsername(), dto.getPassword()); + SVNCommitClient commitClient = new SVNCommitClient(manager, svnOption); try { - - if (log.isDebugEnabled()) { - log.debug("Do Checkout of " + svnRoot); - } - upclient.doCheckout(SVNURL.parseURIEncoded(svnRoot), checkoutdir, - SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, false); + commitClient.doImport(dto.getUpload(), SVNURL.parseURIEncoded(dto.getScmPath() + "/" + dto.getUploadFileName()), + "From scmwebeditor -- add the file : " + dto.getUploadFileName(), null, false, false, SVNDepth.EMPTY); } catch (SVNAuthenticationException authexep) { - // if svn authentication failed user is redirected on login page - if (log.isDebugEnabled()) { - log.debug("Private SCM on reading " + remoteUrl); - } - // deleting the temporary directory - delTempDirectory(checkoutdir); - //redirect to a login page - - resultDto.setError(UploadResultDto.AUTH_ERROR); - return resultDto; - - } catch (SVNException e) { - // deleting the temporary directory - delTempDirectory(checkoutdir); - - resultDto.setError(UploadResultDto.ERROR); - return resultDto; - } - - - // checking whether the path ends with /, if not we add it - if (!svnPath.endsWith("/")) { - svnPath += "/"; - } - - - //Copy file in checkoutdir - String checkoutPath = checkoutdir.getAbsolutePath(); - File file = new File(checkoutPath + dto.getScmPath().replace(svnRoot, ""), dto.getUploadFileName()); - - try { - FileUtils.copyFile(dto.getUpload(), file); - } catch (IOException e) { if (log.isErrorEnabled()) { - log.error("Can't copy the file to the checkout directory", e); + log.error("authentication fail", authexep); } + resultDto.setError(UploadResultDto.AUTH_ERROR); - resultDto.setError(UploadResultDto.ERROR); return resultDto; - } - - - //Commit process - - - try { - - if (log.isDebugEnabled()) { - log.debug("svnPath : " + file.toString()); - } - - // adding the directory - manager.getWCClient().doAdd(file, false, false, false, SVNDepth.EMPTY, false, true); - if (log.isDebugEnabled()) { - log.debug("Add success !"); - } - // adding the file to the versioned files } catch (SVNException e) { - if (log.isErrorEnabled()) { - log.error("Error SVN Add : " + e.getMessage() + " ; " + e.toString(), e); - } - // deleting the temporary directory - delTempDirectory(checkoutdir); - - resultDto.setError(UploadResultDto.CONNECTION_FAILED); - return resultDto; - } - - File[] checkoutDirTab = new File[1]; - checkoutDirTab[0] = checkoutdir; - - try { - manager.getCommitClient().doCommit(checkoutDirTab, false, "From scmwebeditor -- add the file : " + - dto.getUploadFileName(), null, null, false, true, SVNDepth.INFINITY); - - if (log.isDebugEnabled()) { - log.debug("Commit success !"); - } - - } catch (SVNAuthenticationException authexep) { - if (log.isErrorEnabled()) { - log.error("authentication fail", authexep); - } - // deleting the temporary directory - delTempDirectory(checkoutdir); - resultDto.setError(UploadResultDto.AUTH_ERROR); - return resultDto; - } catch (SVNException e) { if (log.isErrorEnabled()) { - log.error("Error SVN commit", e); + log.error("Error SVN import", e); } - // deleting the temporary directory - delTempDirectory(checkoutdir); - resultDto.setError(UploadResultDto.ERROR); - return resultDto; - } - - - // deleting the temporary directory - delTempDirectory(checkoutdir); - if (log.isDebugEnabled()) { - log.debug("File upload successful"); - } + return resultDto; - if (log.isInfoEnabled()) { - log.info(dto.getUsername() + " add the file " + dto.getUploadFileName() + " on the repository."); } return resultDto; @@ -626,12 +511,17 @@ public class SvnConnection implements ScmConnection { } resultDto.setScmRoot(getSvnRoot(dto.getUsername(), dto.getPassword())); - resultDto.setFileRoot(svnPath); if (resultDto.getScmRoot() == null) { resultDto.setScmRoot(svnPath); } + if (svnPath.endsWith("/")) { + resultDto.setFileRoot(svnPath.substring(0, svnPath.lastIndexOf('/'))); + } else { + resultDto.setFileRoot(svnPath); + } + updateAuthentication(dto.getUsername(), dto.getPassword()); try { @@ -641,157 +531,42 @@ public class SvnConnection implements ScmConnection { log.debug("Test connection fail", e); } - resultDto.setError(RemoveResultDto.CONNECTION_FAILED); + resultDto.setError(UploadResultDto.CONNECTION_FAILED); return resultDto; } // if there is no file to remove we get back to the remove form if (dto.getScmPath() == null) { - resultDto.setError(RemoveResultDto.REDIRECT); - return resultDto; - } - if (dto.getScmPath().equals("")) { - resultDto.setError(RemoveResultDto.REDIRECT); - return resultDto; - } - - if (log.isDebugEnabled()) { - log.debug("FileName : " + dto.getScmPath()); - } - - /* - * Checkout process - */ - SVNUpdateClient upclient = new SVNUpdateClient(manager, svnOption); - - checkoutdir = null; - try { - createCheckoutdir(); - } catch (IOException e1) { - if (log.isErrorEnabled()) { - log.error("Can't create checkoutDir", e1); - } - resultDto.setError(RemoveResultDto.ERROR); + resultDto.setError(UploadResultDto.REDIRECT); return resultDto; } - String svnRoot = getSvnRoot(dto.getUsername(), dto.getPassword()); + SVNCommitClient commitClient = new SVNCommitClient(manager, svnOption); try { - - if (log.isDebugEnabled()) { - log.debug("Do Checkout of " + svnRoot); - } - upclient.doCheckout(SVNURL.parseURIEncoded(svnRoot), checkoutdir, - SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, false); + SVNURL scmPathTab[] = new SVNURL[1]; + scmPathTab[0] = SVNURL.parseURIEncoded(dto.getScmPath()); + commitClient.doDelete(scmPathTab, "From scmwebeditor -- remove the file : " + dto.getScmPath()); } catch (SVNAuthenticationException authexep) { - // if svn authentication failed user is redirected on login page - if (log.isDebugEnabled()) { - log.debug("Private SCM on reading " + remoteUrl); - } - // deleting the temporary directory - delTempDirectory(checkoutdir); - //redirect to a login page - - resultDto.setError(RemoveResultDto.AUTH_ERROR); - return resultDto; - - } catch (SVNException e) { - // deleting the temporary directory - delTempDirectory(checkoutdir); - - resultDto.setError(RemoveResultDto.ERROR); - return resultDto; - } - - - // checking whether the path ends with /, if not we add it - if (!svnPath.endsWith("/")) { - svnPath += "/"; - } - - - // Remove file from checkoutdir - String checkoutPath = checkoutdir.getAbsolutePath(); - - File file = new File(checkoutPath + dto.getScmPath().replace(svnRoot, "")); - if (log.isDebugEnabled()) { - - } - file.delete(); - - - try { - - if (log.isDebugEnabled()) { - log.debug("svnPath : " + file.toString()); - } - - // adding the directory - manager.getWCClient().doDelete(file, false, false); - if (log.isDebugEnabled()) { - log.debug("Delete success !"); - } - // adding the file to the versioned files - - } catch (SVNException e) { if (log.isErrorEnabled()) { - log.error("Error SVN delete : " + e.getMessage() + " ; " + e.toString(), e); + log.error("authentication fail", authexep); } - // deleting the temporary directory - delTempDirectory(checkoutdir); + resultDto.setError(UploadResultDto.AUTH_ERROR); - resultDto.setError(RemoveResultDto.CONNECTION_FAILED); return resultDto; - } - - File[] checkoutDirTab = new File[1]; - checkoutDirTab[0] = checkoutdir; - - - //Commit process - try { - manager.getCommitClient().doCommit(checkoutDirTab, false, "From scmwebeditor -- remove the file : " + - dto.getScmPath(), null, null, false, true, SVNDepth.INFINITY); - - if (log.isDebugEnabled()) { - log.debug("Commit success !"); - } - - } catch (SVNAuthenticationException authexep) { - if (log.isErrorEnabled()) { - log.error("authentication fail"); - } - // deleting the temporary directory - delTempDirectory(checkoutdir); - - resultDto.setError(RemoveResultDto.AUTH_ERROR); - return resultDto; } catch (SVNException e) { + if (log.isErrorEnabled()) { - log.error("Error SVN commit", e); + log.error("Error SVN import", e); } - // deleting the temporary directory - delTempDirectory(checkoutdir); + resultDto.setError(UploadResultDto.ERROR); - resultDto.setError(RemoveResultDto.ERROR); return resultDto; - } - - // deleting the temporary directory - delTempDirectory(checkoutdir); - - if (log.isDebugEnabled()) { - log.debug("File upload successful"); - } - - if (log.isInfoEnabled()) { - log.info(dto.getUsername() + " remove the file " + dto.getScmPath() + " on the repository."); } return resultDto; -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm