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 3f4ab8cde497f9bc24bce5c3e6b18c850d5f06e2 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Fri Jun 19 14:48:07 2015 +0200 Improve code quality and fix the mixed content errors --- .../org/nuiton/scmwebeditor/git/GitConnection.java | 175 ++++++--------------- .../org/nuiton/scmwebeditor/git/GitProvider.java | 10 -- .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 17 +- .../main/webapp/WEB-INF/content/imageViewer.jsp | 2 +- .../webapp/WEB-INF/content/modificationViewer.jsp | 6 +- .../main/webapp/WEB-INF/content/outConnection.jsp | 2 +- swe-ui-web/src/main/webapp/js/popup.js | 3 +- swe-ui-web/src/main/webapp/js/preview.js | 1 + swe-ui-web/src/main/webapp/js/selectLanguage.js | 4 +- 9 files changed, 72 insertions(+), 148 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 a7a3144..5b070c9 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 @@ -152,21 +152,6 @@ public class GitConnection implements ScmConnection { resultDto.setError(BrowseResultDto.ERROR); return resultDto; - } catch (IOException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - resultDto.setError(BrowseResultDto.ERROR); - return resultDto; - - } catch (AuthenticationException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - resultDto.setError(BrowseResultDto.AUTH_ERROR); - return resultDto; } String url; @@ -328,21 +313,6 @@ public class GitConnection implements ScmConnection { resultDto.setError(CommitResultDto.ERROR); return resultDto; - } catch (IOException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - resultDto.setError(CommitResultDto.ERROR); - return resultDto; - - } catch (AuthenticationException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - resultDto.setError(CommitResultDto.AUTH_ERROR); - return resultDto; } if (log.isDebugEnabled()) { @@ -454,11 +424,6 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - } catch (IOException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } } File fileToEdit = new File(localDirectory.getAbsolutePath() + File.separator + fileName); @@ -481,11 +446,6 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning or pulling the repository", e); } - } catch (IOException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } } String headRevision = null; @@ -522,20 +482,10 @@ public class GitConnection implements ScmConnection { log.error("Error while cloning or pulling the repository", e); } return null; - } catch (IOException e) { - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - return null; - } catch (AuthenticationException e) { - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - return null; } String path = localDirectory.getAbsolutePath() + address.replace(repositoryRoot, ""); - path.replaceAll("/", File.separator); + path = path.replaceAll("/", File.separator); return path; } @@ -556,19 +506,6 @@ public class GitConnection implements ScmConnection { } return null; - } catch (IOException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - return null; - - } catch (AuthenticationException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - return null; } try { @@ -634,17 +571,6 @@ public class GitConnection implements ScmConnection { log.error("Error while cloning or pulling the repository", e); } - } catch (IOException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - - } catch (AuthenticationException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } } String pathOnRepo = path.replace(addressGit + "/", ""); @@ -703,17 +629,6 @@ public class GitConnection implements ScmConnection { log.error("Error while cloning or pulling the repository", e); } - } catch (IOException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } - - } catch (AuthenticationException e) { - - if (log.isErrorEnabled()) { - log.error("Error while cloning or pulling the repository", e); - } } String pathOnRepo = path.replace(addressGit + "/", ""); @@ -812,11 +727,8 @@ public class GitConnection implements ScmConnection { * @param username the username to use to connect to the repository * @param password the password to use to connect to the repository * @throws RepositoryNotFoundException if the repository is not found - * @throws IOException if it is not possible to reach the repository - * @throws AuthenticationException if there is a problem during the authentication process */ - public void updateRepository(String username, String password) - throws RepositoryNotFoundException, IOException, AuthenticationException { + public void updateRepository(String username, String password) throws RepositoryNotFoundException { // Cloning the remote repository to a local directory String hashedAddress = addressGit; @@ -835,50 +747,60 @@ public class GitConnection implements ScmConnection { credentials = new UsernamePasswordCredentialsProvider(username, password); } - if (!localDirectory.exists()) { + try { + if (!localDirectory.exists()) { - cloneRepository(credentials); + cloneRepository(credentials); - } else { + } else { - Git git = Git.open(localDirectory); + Git git = Git.open(localDirectory); - PullCommand pull = git.pull(); - pull.setCredentialsProvider(credentials); + PullCommand pull = git.pull(); + pull.setCredentialsProvider(credentials); - try { - pull.call(); - } catch (InvalidRemoteException e) { - if (log.isErrorEnabled()) { - log.error("Can't pull the remote repository", e); - } - cloneRepository(credentials); + try { + pull.call(); + } catch (InvalidRemoteException e) { + if (log.isErrorEnabled()) { + log.error("Can't pull the remote repository", e); + } + cloneRepository(credentials); - } catch (JGitInternalException e) { - if (log.isErrorEnabled()) { - log.error("Can't pull the remote repository", e); - } - cloneRepository(credentials); + } catch (JGitInternalException e) { + 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); - } + } catch (TransportException e) { + if (log.isErrorEnabled()) { + log.error("Can't pull the remote repository: " + addressGit, e); + } - if (e.getMessage().endsWith("500 Internal Server Error")) { - throw new AuthenticationException("Can not pull the Git repository: auth failed"); - } else { + if (e.getMessage().endsWith("500 Internal Server Error")) { + throw new AuthenticationException("Can not pull the Git repository: auth failed"); + } else { + cloneRepository(credentials); + } + } catch (GitAPIException e) { + if (log.isErrorEnabled()) { + log.error("Can't pull the remote repository", e); + } cloneRepository(credentials); } - } catch (GitAPIException e) { - if (log.isErrorEnabled()) { - log.error("Can't pull the remote repository", e); + + if (log.isDebugEnabled()) { + log.debug("Pulled repository " + addressGit); } - cloneRepository(credentials); } - - if (log.isDebugEnabled()) { - log.debug("Pulled repository " + addressGit); + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Can not clone repository " + addressGit); + } + } catch (AuthenticationException e) { + if (log.isErrorEnabled()) { + log.error("Can not clone repository " + addressGit + ": authentication error"); } } @@ -891,7 +813,14 @@ public class GitConnection implements ScmConnection { File gitFile = new File(localDirectory.getAbsolutePath() + File.separator + REPOSITORY_EXTENSION); FileRepositoryBuilder gitRepoBuilder = new FileRepositoryBuilder(); gitRepoBuilder.setGitDir(gitFile); - gitRepo = gitRepoBuilder.build(); + + try { + gitRepo = gitRepoBuilder.build(); + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Can not get repository at address " + addressGit); + } + } if (!gitRepo.getObjectDatabase().exists()) { diff --git a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitProvider.java b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitProvider.java index d57a520..f6da5bd 100644 --- a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitProvider.java +++ b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitProvider.java @@ -227,16 +227,6 @@ public class GitProvider implements ScmProvider { log.error("Can not reach repository " + address, e); } error = AbstractResultDto.ERROR; - } catch (IOException e) { - if (log.isErrorEnabled()) { - log.error("Can not reach repository " + address, e); - } - error = AbstractResultDto.ERROR; - } catch (AuthenticationException e) { - if (log.isErrorEnabled()) { - log.error("Authentication problem for repository at address " + address, e); - } - error = AbstractResultDto.AUTH_ERROR; } return error; 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 f96dbd1..ebfdc7d 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 @@ -376,7 +376,8 @@ public class SvnConnection implements ScmConnection { if (log.isDebugEnabled()) { log.debug("Try to commit"); } - commitClient.doCommit(tabFile, false, "From scmwebeditor -- " + dto.getCommitMessage(), null, null, false, false, SVNDepth.FILES); + commitClient.doCommit(tabFile, false, "From scmwebeditor -- " + dto.getCommitMessage(), null, null, false, + false, SVNDepth.FILES); } catch (SVNAuthenticationException authexep) { if (log.isErrorEnabled()) { log.error("AUTH FAIL", authexep); @@ -820,7 +821,7 @@ public class SvnConnection implements ScmConnection { repositoryRoot = repository.getRepositoryRoot(true).toString(); } catch (SVNException e) { if (log.isDebugEnabled()) { - log.debug("Can't get SvnRoot for address " + addressSvn + " ; " + e.getMessage() + " ; " + e.toString() + " ; username == " + username + " ; password == " + password, e); + log.debug("Can't get SvnRoot for address " + addressSvn, e); } return null; } @@ -864,7 +865,8 @@ public class SvnConnection implements ScmConnection { ByteArrayOutputStream diff = new ByteArrayOutputStream(); try { - diffClient.doDiff(pathToFile, SVNRevision.UNDEFINED, SVNRevision.WORKING, SVNRevision.HEAD, SVNDepth.INFINITY, true, diff, null); + diffClient.doDiff(pathToFile, SVNRevision.UNDEFINED, SVNRevision.WORKING, SVNRevision.HEAD, + SVNDepth.INFINITY, true, diff, null); } catch (SVNException e) { log.error("Diff fail", e); } @@ -974,14 +976,15 @@ public class SvnConnection implements ScmConnection { if (log.isDebugEnabled()) { log.debug("/" + (path.equals("") ? "" : path + "/") + ((SVNDirEntry) entry).getName() + "\n"); } - String fichier = address + File.separator + (path.equals("") ? "" : path + File.separator) + ((SVNDirEntry) entry).getName(); + String file = address + File.separator + (path.equals("") ? "" : path + File.separator) + + ((SVNDirEntry) entry).getName(); if (((SVNDirEntry) entry).getKind() == SVNNodeKind.DIR) { - resultDto.getDirectories().put(getAddressUnique(fichier), fichier); + resultDto.getDirectories().put(getAddressUnique(file), file); } else { // only adding the files to the files list and not the directories - resultDto.getFiles().add(fichier); + resultDto.getFiles().add(file); } } } @@ -995,7 +998,7 @@ public class SvnConnection implements ScmConnection { public String getAddressUnique(String fileName) { String result = fileName.replaceAll("/|:", ""); if (log.isDebugEnabled()) { - log.debug("Result of getAddressUnique : " + result + " ; " + fileName); + log.debug("Result of getAddressUnique : " + result); } return result; } diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/imageViewer.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/imageViewer.jsp index a45d49d..d3dd768 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/imageViewer.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/imageViewer.jsp @@ -38,7 +38,7 @@ <script src="js/popup.js" type="text/javascript"></script> <link rel="icon" href="img/edit-icon.png" type="image/png"> - <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="css/main.css"> <script type="text/javascript" src="js/popin.js"></script> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp index bd40bee..3b36757 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp @@ -58,8 +58,8 @@ <script type="text/javascript" src="js/selectLanguage.js"></script> <script type="text/javascript" src="js/popin.js"></script> - <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.min.css"> - <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> + <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.min.css"> + <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> <!-- Code mirror --> <script src="webjars/codemirror/5.1/lib/codemirror.js" type="text/javascript"></script> @@ -79,7 +79,7 @@ <script src="codemirror-ui/js/codemirror-ui.js"></script> <link rel="stylesheet" href="codemirror-ui/css/codemirror-ui.css" type="text/css" media="screen"/> - <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> <script src="js/cancelRedirect.js" type="text/javascript"></script> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/outConnection.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/outConnection.jsp index b37d7f4..c579a61 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/outConnection.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/outConnection.jsp @@ -33,7 +33,7 @@ <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="img/edit-icon.png" type="image/png"> - <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="css/main.css"> <title><s:text name="scm.titles.swe"/></title> diff --git a/swe-ui-web/src/main/webapp/js/popup.js b/swe-ui-web/src/main/webapp/js/popup.js index 6fd3c5e..af94b65 100644 --- a/swe-ui-web/src/main/webapp/js/popup.js +++ b/swe-ui-web/src/main/webapp/js/popup.js @@ -21,5 +21,6 @@ */ function open_popup(page, name, fileAddress, scmType) { - window.open (page+'?address=' + fileAddress + '&scmType=' + scmType, name, config='top=200, left=300, height=600, width=700, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') + window.open (page+'?address=' + fileAddress + '&scmType=' + scmType, name, + config='top=200, left=300, height=600, width=700, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no'); } diff --git a/swe-ui-web/src/main/webapp/js/preview.js b/swe-ui-web/src/main/webapp/js/preview.js index 87f9aba..beb0999 100644 --- a/swe-ui-web/src/main/webapp/js/preview.js +++ b/swe-ui-web/src/main/webapp/js/preview.js @@ -24,6 +24,7 @@ // preview var lastValue = ""; +// updates the preview content function updatePreview() { if (lastValue !== editor.getValue()) { diff --git a/swe-ui-web/src/main/webapp/js/selectLanguage.js b/swe-ui-web/src/main/webapp/js/selectLanguage.js index b57741a..748453c 100644 --- a/swe-ui-web/src/main/webapp/js/selectLanguage.js +++ b/swe-ui-web/src/main/webapp/js/selectLanguage.js @@ -23,7 +23,7 @@ function contains(text, test) { - if(text.indexOf(test) === -1) { + if (text.indexOf(test) === -1) { return false; } else { return true; @@ -37,7 +37,7 @@ function changeModeBy(CodeMirrorEditor, select){ } - +/* select a language for the editor's syntax highlighting */ function selectLanguage(mimetype, format) { var typeEditor = null; -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.