branch feature/GIT updated (91ccf0c -> ffb6cce)
This is an automated email from the git hooks/post-receive script. New change to branch feature/GIT in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git from 91ccf0c Add a RuntimeException class: SweInternalException new ffb6cce Make a git clone when a git pull fails 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 ffb6cce055602c5528f4f2247918b60795bfcac9 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Wed May 13 12:15:58 2015 +0200 Make a git clone when a git pull fails Summary of changes: .../org/nuiton/scmwebeditor/git/GitConnection.java | 100 +++++++++++---------- swe-git/src/main/resources/log4j.properties | 54 ----------- .../scmwebeditor/api/ScmNotFoundException.java | 4 + swe-scm-api/src/main/resources/log4j.properties | 54 ----------- swe-svn/src/main/resources/log4j.properties | 54 ----------- 5 files changed, 59 insertions(+), 207 deletions(-) delete mode 100644 swe-git/src/main/resources/log4j.properties delete mode 100644 swe-scm-api/src/main/resources/log4j.properties delete mode 100644 swe-svn/src/main/resources/log4j.properties -- 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 feature/GIT in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit ffb6cce055602c5528f4f2247918b60795bfcac9 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Wed May 13 12:15:58 2015 +0200 Make a git clone when a git pull fails --- .../org/nuiton/scmwebeditor/git/GitConnection.java | 100 +++++++++++---------- swe-git/src/main/resources/log4j.properties | 54 ----------- .../scmwebeditor/api/ScmNotFoundException.java | 4 + swe-scm-api/src/main/resources/log4j.properties | 54 ----------- swe-svn/src/main/resources/log4j.properties | 54 ----------- 5 files changed, 59 insertions(+), 207 deletions(-) diff --git a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java index 2faea0b..38f69ed 100644 --- a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java +++ b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java @@ -113,7 +113,7 @@ public class GitConnection implements ScmConnection { BrowseResultDto resultDto = new BrowseResultDto(); try { - cloneRepository(dto.getUsername(), dto.getPassword()); + updateRepository(dto.getUsername(), dto.getPassword()); } catch (ScmNotFoundException e) { if (log.isErrorEnabled()) { @@ -285,7 +285,7 @@ public class GitConnection implements ScmConnection { CommitResultDto resultDto = new CommitResultDto(); try { - cloneRepository(dto.getUsername(), dto.getPassword()); + updateRepository(dto.getUsername(), dto.getPassword()); } catch (ScmNotFoundException e) { if (log.isErrorEnabled()) { @@ -452,7 +452,7 @@ public class GitConnection implements ScmConnection { UploadResultDto resultDto = new UploadResultDto(); try { - cloneRepository(dto.getUsername(), dto.getPassword()); + updateRepository(dto.getUsername(), dto.getPassword()); } catch (ScmNotFoundException e) { if (log.isErrorEnabled()) { @@ -635,7 +635,7 @@ public class GitConnection implements ScmConnection { public File getFileContent(String path, String username, String password) throws AuthenticationException { try { - cloneRepository(username, password); + updateRepository(username, password); } catch (ScmNotFoundException e) { if (log.isErrorEnabled()) { @@ -657,7 +657,7 @@ public class GitConnection implements ScmConnection { public String getHeadRevisionNumber(String path, String username, String password) throws AuthenticationException { try { - cloneRepository(username, password); + updateRepository(username, password); } catch (ScmNotFoundException e) { if (log.isErrorEnabled()) { @@ -727,7 +727,7 @@ public class GitConnection implements ScmConnection { } - public void cloneRepository(String username, String password) + public void updateRepository(String username, String password) throws ScmNotFoundException, IOException, AuthenticationException { // Cloning the remote repository to a local directory @@ -750,43 +750,7 @@ public class GitConnection implements ScmConnection { if (!localDirectory.exists()) { - CloneCommand clone = Git.cloneRepository(); - clone.setURI(addressGit); - clone.setDirectory(localDirectory); - - if (username != null && password != null) { - clone.setCredentialsProvider(credentials); - } - - try { - clone.call(); - } catch (InvalidRemoteException e) { - FileUtils.deleteDirectory(localDirectory); - if (log.isErrorEnabled()) { - log.error("Can't clone the remote repository", e); - } - } catch (TransportException e) { - FileUtils.deleteDirectory(localDirectory); - if (log.isErrorEnabled()) { - log.error("Can't clone the remote repository: " + addressGit, e); - } - - if (e.getMessage().endsWith("500 Internal Server Error")) { - throw new AuthenticationException("Can not clone the Git repository: auth failed"); - } else { - throw new ScmNotFoundException("Can not find a Git repository at address " + addressGit); - } - } catch (GitAPIException e) { - FileUtils.deleteDirectory(localDirectory); - if (log.isErrorEnabled()) { - log.error("Can't clone the remote repository", e); - } - throw new ScmNotFoundException("Can not find a Git repository at address " + addressGit); - } - - if (log.isDebugEnabled()) { - log.debug("Cloned repository " + addressGit); - } + cloneRepository(credentials); } else { @@ -801,6 +765,8 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Can't pull the remote repository", e); } + cloneRepository(credentials); + } catch (TransportException e) { if (log.isErrorEnabled()) { log.error("Can't pull the remote repository: " + addressGit, e); @@ -809,13 +775,13 @@ public class GitConnection implements ScmConnection { if (e.getMessage().endsWith("500 Internal Server Error")) { throw new AuthenticationException("Can not pull the Git repository: auth failed"); } else { - throw new ScmNotFoundException("Can not find a Git repository at address " + addressGit); + cloneRepository(credentials); } } catch (GitAPIException e) { if (log.isErrorEnabled()) { log.error("Can't pull the remote repository", e); } - throw new ScmNotFoundException("Can not find a Git repository at address " + addressGit); + cloneRepository(credentials); } if (log.isDebugEnabled()) { @@ -844,6 +810,50 @@ public class GitConnection implements ScmConnection { } + protected void cloneRepository(CredentialsProvider credentials) + throws IOException, AuthenticationException, ScmNotFoundException { + + if (localDirectory.exists()) { + FileUtils.deleteDirectory(localDirectory); + } + + CloneCommand clone = Git.cloneRepository(); + clone.setURI(addressGit); + clone.setDirectory(localDirectory); + clone.setCredentialsProvider(credentials); + + try { + clone.call(); + } catch (InvalidRemoteException e) { + FileUtils.deleteDirectory(localDirectory); + if (log.isErrorEnabled()) { + log.error("Can't clone the remote repository", e); + } + } catch (TransportException e) { + FileUtils.deleteDirectory(localDirectory); + if (log.isErrorEnabled()) { + log.error("Can't clone the remote repository: " + addressGit, e); + } + + if (e.getMessage().endsWith("500 Internal Server Error")) { + throw new AuthenticationException("Can not clone the Git repository: auth failed"); + } else { + throw new ScmNotFoundException("Can not find a Git repository at address " + addressGit, e); + } + } catch (GitAPIException e) { + FileUtils.deleteDirectory(localDirectory); + if (log.isErrorEnabled()) { + log.error("Can't clone the remote repository", e); + } + throw new ScmNotFoundException("Can not find a Git repository at address " + addressGit, e); + } + + if (log.isDebugEnabled()) { + log.debug("Cloned repository " + addressGit); + } + } + + /** * Hashes a String with then given algorithms * @param toHash the String to hash diff --git a/swe-git/src/main/resources/log4j.properties b/swe-git/src/main/resources/log4j.properties deleted file mode 100644 index 86b4c81..0000000 --- a/swe-git/src/main/resources/log4j.properties +++ /dev/null @@ -1,54 +0,0 @@ -### -# #%L -# ScmWebEditor -# %% -# Copyright (C) 2009 - 2011 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% -### -# Global logging configuration -log4j.rootLogger=DEBUG, stdout, fileout -#log4j.rootLogger=INFO, stdout - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n - -# File output... -log4j.appender.fileout=org.apache.log4j.FileAppender -log4j.appender.fileout.File=jtimer.log -log4j.appender.fileout.Append=true -log4j.appender.fileout.Threshold=DEBUG -log4j.appender.fileout.layout=org.apache.log4j.PatternLayout -log4j.appender.fileout.layout.ConversionPattern=%5p (%F:%L) %m%n - -# Rolling appender -log4j.appender.rolling=org.apache.log4j.RollingFileAppender -log4j.appender.rolling.File=jtimer.log -log4j.appender.rolling.MaxFileSize=100KB -log4j.appender.rolling.Append=true -log4j.appender.rolling.MaxBackupIndex=30 -log4j.appender.rolling.Threshold=INFO -log4j.appender.rolling.layout=org.apache.log4j.PatternLayout -log4j.appender.rolling.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n - -# package level -log4j.logger.org.nuiton.scmwebeditor.uiweb.actions.SaveAction=DEBUG - -log4j.logger.org.chorem.jtimer=DEBUG -log4j.logger.org.chorem.jtimer.ws=DEBUG -log4j.logger.org.chorem.jtimer.ui.report=DEBUG diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmNotFoundException.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmNotFoundException.java index 02cdf4a..b5ae0bd 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmNotFoundException.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmNotFoundException.java @@ -8,4 +8,8 @@ public class ScmNotFoundException extends Exception { public ScmNotFoundException(String message) { super(message); } + + public ScmNotFoundException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/swe-scm-api/src/main/resources/log4j.properties b/swe-scm-api/src/main/resources/log4j.properties deleted file mode 100644 index 86b4c81..0000000 --- a/swe-scm-api/src/main/resources/log4j.properties +++ /dev/null @@ -1,54 +0,0 @@ -### -# #%L -# ScmWebEditor -# %% -# Copyright (C) 2009 - 2011 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% -### -# Global logging configuration -log4j.rootLogger=DEBUG, stdout, fileout -#log4j.rootLogger=INFO, stdout - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n - -# File output... -log4j.appender.fileout=org.apache.log4j.FileAppender -log4j.appender.fileout.File=jtimer.log -log4j.appender.fileout.Append=true -log4j.appender.fileout.Threshold=DEBUG -log4j.appender.fileout.layout=org.apache.log4j.PatternLayout -log4j.appender.fileout.layout.ConversionPattern=%5p (%F:%L) %m%n - -# Rolling appender -log4j.appender.rolling=org.apache.log4j.RollingFileAppender -log4j.appender.rolling.File=jtimer.log -log4j.appender.rolling.MaxFileSize=100KB -log4j.appender.rolling.Append=true -log4j.appender.rolling.MaxBackupIndex=30 -log4j.appender.rolling.Threshold=INFO -log4j.appender.rolling.layout=org.apache.log4j.PatternLayout -log4j.appender.rolling.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n - -# package level -log4j.logger.org.nuiton.scmwebeditor.uiweb.actions.SaveAction=DEBUG - -log4j.logger.org.chorem.jtimer=DEBUG -log4j.logger.org.chorem.jtimer.ws=DEBUG -log4j.logger.org.chorem.jtimer.ui.report=DEBUG diff --git a/swe-svn/src/main/resources/log4j.properties b/swe-svn/src/main/resources/log4j.properties deleted file mode 100644 index 86b4c81..0000000 --- a/swe-svn/src/main/resources/log4j.properties +++ /dev/null @@ -1,54 +0,0 @@ -### -# #%L -# ScmWebEditor -# %% -# Copyright (C) 2009 - 2011 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% -### -# Global logging configuration -log4j.rootLogger=DEBUG, stdout, fileout -#log4j.rootLogger=INFO, stdout - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n - -# File output... -log4j.appender.fileout=org.apache.log4j.FileAppender -log4j.appender.fileout.File=jtimer.log -log4j.appender.fileout.Append=true -log4j.appender.fileout.Threshold=DEBUG -log4j.appender.fileout.layout=org.apache.log4j.PatternLayout -log4j.appender.fileout.layout.ConversionPattern=%5p (%F:%L) %m%n - -# Rolling appender -log4j.appender.rolling=org.apache.log4j.RollingFileAppender -log4j.appender.rolling.File=jtimer.log -log4j.appender.rolling.MaxFileSize=100KB -log4j.appender.rolling.Append=true -log4j.appender.rolling.MaxBackupIndex=30 -log4j.appender.rolling.Threshold=INFO -log4j.appender.rolling.layout=org.apache.log4j.PatternLayout -log4j.appender.rolling.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n - -# package level -log4j.logger.org.nuiton.scmwebeditor.uiweb.actions.SaveAction=DEBUG - -log4j.logger.org.chorem.jtimer=DEBUG -log4j.logger.org.chorem.jtimer.ws=DEBUG -log4j.logger.org.chorem.jtimer.ui.report=DEBUG -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm