branch develop updated (7c4956d -> dbcbb07)
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 7c4956d Fix translation problems new dbcbb07 Add the ability to remove a file from a repository 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 dbcbb071025009b4aa3cd007a951df4c80143a9a Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Tue May 19 16:47:33 2015 +0200 Add the ability to remove a file from a repository Summary of changes: .../org/nuiton/scmwebeditor/git/GitConnection.java | 290 +++++++++++++++------ .../org/nuiton/scmwebeditor/api/ScmConnection.java | 9 +- .../org/nuiton/scmwebeditor/api/dto/RemoveDto.java | 44 ++-- .../scmwebeditor/api/dto/RemoveResultDto.java | 67 +++++ .../org/nuiton/scmwebeditor/api/dto/UploadDto.java | 2 +- .../scmwebeditor/api/dto/UploadResultDto.java | 2 +- .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 211 ++++++++++++++- .../scmwebeditor/uiweb/actions/BrowseAction.java | 4 + .../{UploadAction.java => RemoveAction.java} | 97 +++---- .../scmwebeditor/uiweb/actions/UploadAction.java | 10 +- .../i18n/scmwebeditor-ui-web_en_GB.properties | 8 +- .../i18n/scmwebeditor-ui-web_fr_FR.properties | 8 +- swe-ui-web/src/main/resources/struts.xml | 7 + .../src/main/webapp/WEB-INF/content/browse.jsp | 15 +- .../webapp/WEB-INF/content/modificationViewer.jsp | 14 +- .../content/{uploadForm.jsp => removeForm.jsp} | 25 +- .../{uploadSuccess.jsp => removeSuccess.jsp} | 4 +- .../src/main/webapp/WEB-INF/content/reset.jsp | 2 +- .../src/main/webapp/WEB-INF/content/upload.jsp | 2 +- .../src/main/webapp/WEB-INF/content/uploadForm.jsp | 2 +- .../main/webapp/WEB-INF/content/uploadSuccess.jsp | 2 +- swe-ui-web/src/main/webapp/css/main.css | 12 + .../main/webapp/js/{pictureUpload.js => popup.js} | 9 +- 23 files changed, 630 insertions(+), 216 deletions(-) copy swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/ScmUser.java => swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java (70%) create mode 100644 swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveResultDto.java copy swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/{UploadAction.java => RemoveAction.java} (74%) copy swe-ui-web/src/main/webapp/WEB-INF/content/{uploadForm.jsp => removeForm.jsp} (80%) copy swe-ui-web/src/main/webapp/WEB-INF/content/{uploadSuccess.jsp => removeSuccess.jsp} (94%) rename swe-ui-web/src/main/webapp/js/{pictureUpload.js => popup.js} (70%) -- 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 dbcbb071025009b4aa3cd007a951df4c80143a9a Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Tue May 19 16:47:33 2015 +0200 Add the ability to remove a file from a repository --- .../org/nuiton/scmwebeditor/git/GitConnection.java | 290 +++++++++++++++------ .../org/nuiton/scmwebeditor/api/ScmConnection.java | 9 +- .../org/nuiton/scmwebeditor/api/dto/RemoveDto.java | 55 ++++ .../scmwebeditor/api/dto/RemoveResultDto.java | 67 +++++ .../org/nuiton/scmwebeditor/api/dto/UploadDto.java | 2 +- .../scmwebeditor/api/dto/UploadResultDto.java | 2 +- .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 211 ++++++++++++++- .../scmwebeditor/uiweb/actions/BrowseAction.java | 4 + .../{UploadAction.java => RemoveAction.java} | 97 +++---- .../scmwebeditor/uiweb/actions/UploadAction.java | 10 +- .../i18n/scmwebeditor-ui-web_en_GB.properties | 8 +- .../i18n/scmwebeditor-ui-web_fr_FR.properties | 8 +- swe-ui-web/src/main/resources/struts.xml | 7 + .../src/main/webapp/WEB-INF/content/browse.jsp | 15 +- .../webapp/WEB-INF/content/modificationViewer.jsp | 14 +- .../content/{uploadForm.jsp => removeForm.jsp} | 25 +- .../{uploadSuccess.jsp => removeSuccess.jsp} | 4 +- .../src/main/webapp/WEB-INF/content/reset.jsp | 2 +- .../src/main/webapp/WEB-INF/content/upload.jsp | 2 +- .../src/main/webapp/WEB-INF/content/uploadForm.jsp | 2 +- .../main/webapp/WEB-INF/content/uploadSuccess.jsp | 2 +- swe-ui-web/src/main/webapp/css/main.css | 12 + .../main/webapp/js/{pictureUpload.js => popup.js} | 9 +- 23 files changed, 666 insertions(+), 191 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 a69440a..296baf8 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 @@ -125,7 +125,7 @@ public class GitConnection implements ScmConnection { } catch (RepositoryNotFoundException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } resultDto.setError(BrowseResultDto.ERROR); return resultDto; @@ -133,7 +133,7 @@ public class GitConnection implements ScmConnection { } catch (IOException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } resultDto.setError(BrowseResultDto.ERROR); return resultDto; @@ -141,7 +141,7 @@ public class GitConnection implements ScmConnection { } catch (AuthenticationException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } resultDto.setError(BrowseResultDto.AUTH_ERROR); return resultDto; @@ -297,7 +297,7 @@ public class GitConnection implements ScmConnection { } catch (RepositoryNotFoundException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } resultDto.setError(CommitResultDto.ERROR); return resultDto; @@ -305,7 +305,7 @@ public class GitConnection implements ScmConnection { } catch (IOException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } resultDto.setError(CommitResultDto.ERROR); return resultDto; @@ -313,7 +313,7 @@ public class GitConnection implements ScmConnection { } catch (AuthenticationException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } resultDto.setError(CommitResultDto.AUTH_ERROR); return resultDto; @@ -399,47 +399,32 @@ public class GitConnection implements ScmConnection { try { push.call(); - } catch (NoHeadException e) { - if (log.isErrorEnabled()) { - log.error("Can not push : the Git repository has no HEAD reference", e); - } - - resultDto.setError(CommitResultDto.ERROR); - return resultDto; - } catch (UnmergedPathsException e) { - if (log.isErrorEnabled()) { - log.error("Can not push : conflicts found (unmerged paths)", e); - } - - resultDto.setError(CommitResultDto.ERROR); - return resultDto; - } catch (ConcurrentRefUpdateException e) { - if (log.isErrorEnabled()) { - log.error("Can not push : someone else is updating the HEAD or the branch", e); - } + } catch (GitAPIException e) { - resultDto.setError(CommitResultDto.ERROR); - return resultDto; - } catch (WrongRepositoryStateException e) { - if (log.isErrorEnabled()) { - log.error("Can not push : the repository is not in the right state", e); + String logMessage = "Can not push"; + + if (e instanceof NoHeadException) { + logMessage = "Can not push : the Git repository has no HEAD reference"; + } else if (e instanceof UnmergedPathsException) { + logMessage = "Can not push : conflicts found (unmerged paths)"; + } else if (e instanceof ConcurrentRefUpdateException) { + logMessage = "Can not push : someone else is updating the HEAD or the branch"; + } else if (e instanceof WrongRepositoryStateException) { + logMessage = "Can not push : the repository is not in the right state"; + } else if (e instanceof RejectCommitException) { + logMessage = "Can not push : commit rejected"; } - resultDto.setError(CommitResultDto.ERROR); - return resultDto; - } catch (RejectCommitException e) { if (log.isErrorEnabled()) { - log.error("Can not push : commit rejected", e); + log.error(logMessage, e); } - resultDto.setError(CommitResultDto.ERROR); - return resultDto; - } catch (GitAPIException e) { - if (log.isErrorEnabled()) { - log.error("Can not push", e); + if (e.getMessage().endsWith("not authorized")) { + resultDto.setError(RemoveResultDto.AUTH_ERROR); + } else { + resultDto.setError(RemoveResultDto.ERROR); } - resultDto.setError(CommitResultDto.AUTH_ERROR); return resultDto; } } catch (IOException e) { @@ -464,7 +449,7 @@ public class GitConnection implements ScmConnection { } catch (RepositoryNotFoundException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } resultDto.setError(UploadResultDto.ERROR); @@ -473,7 +458,7 @@ public class GitConnection implements ScmConnection { } catch (IOException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } resultDto.setError(UploadResultDto.ERROR); return resultDto; @@ -481,7 +466,7 @@ public class GitConnection implements ScmConnection { } catch (AuthenticationException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } resultDto.setError(UploadResultDto.AUTH_ERROR); return resultDto; @@ -507,7 +492,7 @@ public class GitConnection implements ScmConnection { if (pathOnRepo.length() > addressGit.length()) { pathOnRepo = pathOnRepo.substring(addressGit.length() + 1); - path = pathOnRepo + "/" + dto.getUploadFileName(); + path = pathOnRepo + File.separator + dto.getUploadFileName(); } else { path = dto.getUploadFileName(); } @@ -583,56 +568,208 @@ public class GitConnection implements ScmConnection { try { push.call(); - } catch (NoHeadException e) { - if (log.isErrorEnabled()) { - log.error("Can not push : the Git repository has no HEAD reference", e); - } + } catch (GitAPIException e) { + + String logMessage = "Can not push"; file.delete(); - resultDto.setError(UploadResultDto.ERROR); - return resultDto; - } catch (UnmergedPathsException e) { - if (log.isErrorEnabled()) { - log.error("Can not push : conflicts found (unmerged paths)", e); + + if (e instanceof NoHeadException) { + logMessage = "Can not push : the Git repository has no HEAD reference"; + } else if (e instanceof UnmergedPathsException) { + logMessage = "Can not push : conflicts found (unmerged paths)"; + } else if (e instanceof ConcurrentRefUpdateException) { + logMessage = "Can not push : someone else is updating the HEAD or the branch"; + } else if (e instanceof WrongRepositoryStateException) { + logMessage = "Can not push : the repository is not in the right state"; + } else if (e instanceof RejectCommitException) { + logMessage = "Can not push : commit rejected"; } - file.delete(); - resultDto.setError(UploadResultDto.ERROR); - return resultDto; - } catch (ConcurrentRefUpdateException e) { if (log.isErrorEnabled()) { - log.error("Can not push : someone else is updating the HEAD or the branch", e); + log.error(logMessage, e); + } + + if (e.getMessage().endsWith("not authorized")) { + resultDto.setError(RemoveResultDto.AUTH_ERROR); + } else { + resultDto.setError(RemoveResultDto.ERROR); } - file.delete(); - resultDto.setError(UploadResultDto.ERROR); return resultDto; - } catch (WrongRepositoryStateException e) { + } + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Can not open git local repository : " + localDirectory.getAbsolutePath(), e); + } + + file.delete(); + resultDto.setError(UploadResultDto.ERROR); + return resultDto; + } + + return resultDto; + } + + @Override + public RemoveResultDto removeFile(RemoveDto dto) { + + RemoveResultDto resultDto = new RemoveResultDto(); + + try { + updateRepository(dto.getUsername(), dto.getPassword()); + } catch (RepositoryNotFoundException e) { + + if (log.isErrorEnabled()) { + log.error("Error while cloning or pulling the repository", e); + } + + resultDto.setError(RemoveResultDto.ERROR); + return resultDto; + + } catch (IOException e) { + + if (log.isErrorEnabled()) { + log.error("Error while cloning or pulling the repository", e); + } + resultDto.setError(RemoveResultDto.ERROR); + return resultDto; + + } catch (AuthenticationException e) { + + if (log.isErrorEnabled()) { + log.error("Error while cloning or pulling the repository", e); + } + resultDto.setError(RemoveResultDto.AUTH_ERROR); + return resultDto; + } + + resultDto.setFileRoot(addressGit); + resultDto.setScmRoot(addressGit); + + + // if there is no file to remove, we get back to the remove form + if (dto.getScmPath() == null) { + resultDto.setError(RemoveResultDto.REDIRECT); + return resultDto; + } else if (dto.getScmPath().equals("")) { + resultDto.setError(RemoveResultDto.REDIRECT); + return resultDto; + } else if (dto.getScmPath().equals(addressGit)) { + resultDto.setError(RemoveResultDto.REDIRECT); + return resultDto; + } + + if (log.isDebugEnabled()) { + log.debug("FileName : " + dto.getScmPath()); + } + + // Removing the file from the local directory + String pathOnRepo = dto.getScmPath(); + + if (pathOnRepo.length() > addressGit.length()) { + pathOnRepo = pathOnRepo.replace(addressGit + "/", ""); + } + + File file = new File(localDirectory.getAbsolutePath() + File.separator + pathOnRepo); + + // authentication + if (dto.getUsername() == null) { + dto.setUsername("anonymous"); + } + + if (dto.getPassword() == null) { + dto.setPassword("anonymous"); + } + + CredentialsProvider credentials = new UsernamePasswordCredentialsProvider(dto.getUsername(), dto.getPassword()); + + try { + Git git = Git.open(localDirectory); + + // removing the file + RmCommand rm = git.rm(); + rm.addFilepattern(pathOnRepo); + try { + rm.call(); + } catch (GitAPIException e) { if (log.isErrorEnabled()) { - log.error("Can not push : the repository is not in the right state", e); + log.error("Can not remove Git file " + pathOnRepo, e); } - file.delete(); - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(RemoveResultDto.ERROR); return resultDto; - } catch (RejectCommitException e) { + } + file.delete(); + + // commit + if (log.isDebugEnabled()) { + log.debug("Preparing commit"); + } + + CommitCommand commit = git.commit(); + commit.setAll(true); + commit.setAuthor(dto.getUsername(), "unknown"); + commit.setMessage("From scmwebeditor -- remove the file : " + pathOnRepo); + + try { + commit.call(); + } catch (GitAPIException e) { if (log.isErrorEnabled()) { - log.error("Can not push : commit rejected", e); + log.error("Can not commit", e); } - file.delete(); - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(RemoveResultDto.ERROR); return resultDto; + } + + if (log.isDebugEnabled()) { + log.debug("Preparing push"); + } + + // push + PushCommand push = git.push(); + push.setRemote(addressGit); + push.setCredentialsProvider(credentials); + + try { + push.call(); } catch (GitAPIException e) { + + String logMessage = "Can not push"; + + if (e instanceof NoHeadException) { + logMessage = "Can not push : the Git repository has no HEAD reference"; + } else if (e instanceof UnmergedPathsException) { + logMessage = "Can not push : conflicts found (unmerged paths)"; + } else if (e instanceof ConcurrentRefUpdateException) { + logMessage = "Can not push : someone else is updating the HEAD or the branch"; + } else if (e instanceof WrongRepositoryStateException) { + logMessage = "Can not push : the repository is not in the right state"; + } else if (e instanceof RejectCommitException) { + logMessage = "Can not push : commit rejected"; + } + if (log.isErrorEnabled()) { - log.error("Can not push", e); + log.error(logMessage, e); + } + + try { + cloneRepository(credentials); + } catch (AuthenticationException e1) { + if (log.isErrorEnabled()) { + log.error("Can not clone repository at address " + addressGit); + } + } catch (RepositoryNotFoundException e1) { + if (log.isErrorEnabled()) { + log.error("Can not clone repository at address " + addressGit); + } } - file.delete(); if (e.getMessage().endsWith("not authorized")) { - resultDto.setError(UploadResultDto.AUTH_ERROR); + resultDto.setError(RemoveResultDto.AUTH_ERROR); } else { - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(RemoveResultDto.ERROR); } return resultDto; @@ -642,8 +779,7 @@ public class GitConnection implements ScmConnection { log.error("Can not open git local repository : " + localDirectory.getAbsolutePath(), e); } - file.delete(); - resultDto.setError(UploadResultDto.ERROR); + resultDto.setError(RemoveResultDto.ERROR); return resultDto; } @@ -659,12 +795,12 @@ public class GitConnection implements ScmConnection { } catch (RepositoryNotFoundException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } } catch (IOException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } } @@ -681,12 +817,12 @@ public class GitConnection implements ScmConnection { } catch (RepositoryNotFoundException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } } catch (IOException e) { if (log.isErrorEnabled()) { - log.error("Error while cloning the repository", e); + log.error("Error while cloning or pulling the repository", e); } } diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmConnection.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmConnection.java index a6fb165..bb000b9 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmConnection.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmConnection.java @@ -56,6 +56,14 @@ public interface ScmConnection { /** + * Removes a file from the repository + * @param dto the DTO which contains all the parameters + * @return a DTO which contains all the results + */ + RemoveResultDto removeFile(RemoveDto dto); + + + /** * Gives the content of a file as a String * @param path the path to the file to get the content from * @param username the user's login for the SCM @@ -89,5 +97,4 @@ public interface ScmConnection { * @return the name of the edited file */ String getFileName(); - } diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java new file mode 100644 index 0000000..1e93a8d --- /dev/null +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDto.java @@ -0,0 +1,55 @@ +/* + * #%L + * ScmWebEditor + * %% + * Copyright (C) 2009 - 2015 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% + */ +package org.nuiton.scmwebeditor.api.dto; + +public class RemoveDto { + + /** the username used to connect to the SCM */ + protected String username; + + /** the password used to connect to the SCM */ + protected String password; + + /** path to the repository */ + protected String scmPath; + + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getScmPath() { return scmPath; } + + public void setScmPath(String scmPath) { this.scmPath = scmPath; } +} diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveResultDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveResultDto.java new file mode 100644 index 0000000..47e264c --- /dev/null +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveResultDto.java @@ -0,0 +1,67 @@ +/* + * #%L + * ScmWebEditor + * %% + * Copyright (C) 2009 - 2015 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% + */ +package org.nuiton.scmwebeditor.api.dto; + +public class RemoveResultDto { + + public static String ERROR = "error"; + + public static String REDIRECT = "redirect"; + + public static String CONNECTION_FAILED = "connection failed"; + + public static String AUTH_ERROR = "auth error"; + + /** gives a message about the error if one occured */ + protected String error; + + /** the root directory of the repository */ + protected String scmRoot; + + /** the full path of the file to remove */ + private String fileRoot; + + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } + + public String getScmRoot() { + return scmRoot; + } + + public void setScmRoot(String scmRoot) { + this.scmRoot = scmRoot; + } + + public String getFileRoot() { + return fileRoot; + } + + public void setFileRoot(String fileRoot) { + this.fileRoot = fileRoot; + } +} diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadDto.java index 78b392e..ed7a053 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadDto.java @@ -19,7 +19,7 @@ public class UploadDto { /** the type of the file to upload's content */ protected String uploadContentType; - /** path to the SCM */ + /** path to the repository */ protected String scmPath; diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadResultDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadResultDto.java index e58b3b2..cf1e818 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadResultDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadResultDto.java @@ -16,7 +16,7 @@ public class UploadResultDto { /** the directory which contains the file */ protected String fileRoot; - /** the root direcory of the SCM */ + /** the root direcory of the repository */ protected String scmRoot; 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 6e880a5..14d66de 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 @@ -85,8 +85,9 @@ public class SvnConnection implements ScmConnection { } if (address.lastIndexOf("/") != -1){ - svnPath = address.substring(0, address.lastIndexOf("/")); - fileName = address.substring(address.lastIndexOf("/") + 1); + + svnPath = address.substring(0, address.lastIndexOf('/')); + fileName = address.substring(address.lastIndexOf('/') + 1); } addressSvn = address; @@ -426,15 +427,15 @@ public class SvnConnection implements ScmConnection { } resultDto.setScmRoot(getSvnRoot(dto.getUsername(), dto.getPassword())); - resultDto.setFileRoot(svnPath); if (resultDto.getScmRoot() == null) { - resultDto.setScmRoot(resultDto.getFileRoot()); + resultDto.setScmRoot(svnPath); } - - if (resultDto.getScmRoot() == null) { - resultDto.setScmRoot(resultDto.getFileRoot()); + if (!svnPath.endsWith("/")) { + resultDto.setFileRoot(svnPath.substring(0, svnPath.lastIndexOf('/'))); + } else { + resultDto.setFileRoot(svnPath); } updateAuthentication(dto.getUsername(), dto.getPassword()); @@ -518,9 +519,7 @@ public class SvnConnection implements ScmConnection { //Copy file in checkoutdir - String checkoutPath = checkoutdir.getAbsolutePath(); - File file = new File(checkoutPath + dto.getScmPath().replace(svnRoot, ""), dto.getUploadFileName()); try { @@ -541,7 +540,7 @@ public class SvnConnection implements ScmConnection { try { if (log.isDebugEnabled()) { - log.debug("leSvnPath : " + file.toString()); + log.debug("svnPath : " + file.toString()); } // adding the directory @@ -575,7 +574,7 @@ public class SvnConnection implements ScmConnection { } catch (SVNAuthenticationException authexep) { if (log.isErrorEnabled()) { - log.error("authentification fail"); + log.error("authentication fail", authexep); } // deleting the temporary directory delTempDirectory(checkoutdir); @@ -608,6 +607,191 @@ public class SvnConnection implements ScmConnection { return resultDto; } + @Override + public RemoveResultDto removeFile(RemoveDto dto) { + + RemoveResultDto resultDto = new RemoveResultDto(); + + if (dto.getUsername() == null) { + dto.setUsername("anonymous"); + } + + if (dto.getPassword() == null) { + dto.setPassword("anonymous"); + } + + resultDto.setScmRoot(getSvnRoot(dto.getUsername(), dto.getPassword())); + resultDto.setFileRoot(svnPath); + + if (resultDto.getScmRoot() == null) { + resultDto.setScmRoot(svnPath); + } + + updateAuthentication(dto.getUsername(), dto.getPassword()); + + try { + testConnection(); + } catch (SVNException e) { + if (log.isDebugEnabled()) { + log.debug("Test connection fail", e); + } + + resultDto.setError(RemoveResultDto.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); + return resultDto; + } + + String svnRoot = getSvnRoot(dto.getUsername(), dto.getPassword()); + + try { + + if (log.isDebugEnabled()) { + log.debug("Do Checkout of " + svnRoot); + } + upclient.doCheckout(SVNURL.parseURIEncoded(svnRoot), checkoutdir, + SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, false); + } 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); + } + // deleting the temporary directory + delTempDirectory(checkoutdir); + + 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); + } + // deleting the temporary directory + delTempDirectory(checkoutdir); + + 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; + } + @Override public File getFileContent(String path, String username, String password) throws AuthenticationException { @@ -769,7 +953,7 @@ public class SvnConnection implements ScmConnection { repositoryRoot = repository.getRepositoryRoot(true).toString(); } catch (SVNException e) { if (log.isDebugEnabled()) { - log.debug("Can't get SvnRoot"); + log.debug("Can't get SvnRoot for address " + addressSvn + " ; " + e.getMessage() + " ; " + e.toString() + " ; username == " + username + " ; password == " + password, e); } return null; } @@ -786,6 +970,7 @@ public class SvnConnection implements ScmConnection { public void testConnection() throws SVNException { String encodedUrl = SVNEncodingUtil.autoURIEncode(addressSvn); + SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(encodedUrl)); repository.setAuthenticationManager(authManager); @@ -851,7 +1036,7 @@ public class SvnConnection implements ScmConnection { localDirectory.mkdir(); } - checkoutdir = FileUtil.createTempDirectory(localDirectory.getAbsolutePath() + File.separator + "scm_", ""); + checkoutdir = FileUtil.createTempDirectory("scm_", "", localDirectory); } diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/BrowseAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/BrowseAction.java index 32a4aa2..127837a 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/BrowseAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/BrowseAction.java @@ -250,6 +250,10 @@ public class BrowseAction extends AbstractScmWebEditorAction implements ServletR authCookie.setMaxAge(60 * 60 * 24 * 365); response.addCookie(authCookie); + if (log.isDebugEnabled()) { + log.debug("addscmuser uuid == " + repositoryUUID + " ; username == " + username + " ; pw == " + pw); + } + getScmSession().addScmUser(repositoryUUID, username, pw); } } diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveAction.java similarity index 74% copy from swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java copy to swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveAction.java index a005074..4de4099 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveAction.java @@ -27,33 +27,24 @@ import org.apache.struts2.interceptor.ServletRequestAware; import org.nuiton.scmwebeditor.api.ScmConnection; import org.nuiton.scmwebeditor.api.ScmProvider; import org.nuiton.scmwebeditor.api.ScmWebEditorConfig; -import org.nuiton.scmwebeditor.api.dto.UploadDto; -import org.nuiton.scmwebeditor.api.dto.UploadResultDto; +import org.nuiton.scmwebeditor.api.dto.RemoveDto; +import org.nuiton.scmwebeditor.api.dto.RemoveResultDto; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import java.io.File; /** - * Uploads a file from the client to the repository + * Removes a file from the repository */ -public class UploadAction extends AbstractScmWebEditorAction implements ServletRequestAware { +public class RemoveAction extends AbstractScmWebEditorAction implements ServletRequestAware { private static final long serialVersionUID = 4244339447567114412L; - private static final Log log = LogFactory.getLog(UploadAction.class); + private static final Log log = LogFactory.getLog(RemoveAction.class); public static final String REDIRECT = "redirect"; - /** the file to upload */ - protected File upload; - - /** the name of the file to upload */ - protected String uploadFileName; - - /** the type of the file to upload */ - protected String uploadContentType; - /** the username to use to connect to the repository */ protected String username; @@ -66,12 +57,6 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR /** the URL the root of the repository */ protected String scmRoot; - /** the full path where the file will be uploaded */ - protected String fileRoot; - - /** the path to the directory where the file will be uploaded to */ - protected String scmPath; - /** equals true if there is a problem during the authentication process */ protected boolean badLogin; @@ -81,29 +66,12 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR /** the HTTP request sent to the server */ protected transient HttpServletRequest request; - public File getUpload() { - return upload; - } - - public void setUpload(File upload) { - this.upload = upload; - } - - public String getUploadContentType() { - return uploadContentType; - } - - public void setUploadContentType(String uploadContentType) { - this.uploadContentType = uploadContentType; - } + /** the full path to the file to remove */ + protected String scmPath; - public String getUploadFileName() { - return uploadFileName; - } + /** the full path of the file to remove */ + protected String fileRoot; - public void setUploadFileName(String uploadFileName) { - this.uploadFileName = uploadFileName; - } public String getUsername() { return username; @@ -141,27 +109,24 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR return scmRoot; } - public String getFileRoot() { - return fileRoot; - } - public void setScmRoot(String scmRoot) { this.scmRoot = scmRoot; } - public void setFileRoot(String fileRoot) { this.fileRoot = fileRoot; } - public void setBadLogin(boolean badLogin) { this.badLogin = badLogin; } public void setError(boolean error) { this.error = error; } - public void setScmPath(String scmPath) { this.scmPath = scmPath; } + public HttpServletRequest getRequest() { return request; } public String getScmPath() { return scmPath; } - public HttpServletRequest getRequest() { return request; } + public void setScmPath(String scmPath) { this.scmPath = scmPath; } + + public String getFileRoot() { return fileRoot; } + public void setFileRoot(String fileRoot) { this.fileRoot = fileRoot; } /** - * Execution of the upload action + * Execution of the remove action * @return a code interpreted in the file struts.xml */ public String execute() { @@ -175,6 +140,10 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR ScmConnection scmConn = provider.getConnection(address, pathToLocalRepos); // if the repository is not protected for writing, we get its UUID + if (address.endsWith("/")) { + address = address.substring(0, address.lastIndexOf('/')); + } + String repositoryUUID = scmConn.getRepositoryId(); if (repositoryUUID == null) { repositoryUUID = address.replace(' ', '_'); @@ -184,34 +153,34 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR username = usernamePw[0]; pw = usernamePw[1]; - UploadDto dto = new UploadDto(); + RemoveDto dto = new RemoveDto(); dto.setUsername(username); dto.setPassword(pw); - dto.setUpload(upload); - dto.setUploadFileName(uploadFileName); - dto.setUploadContentType(uploadContentType); dto.setScmPath(scmPath); - UploadResultDto resultDto = scmConn.uploadFile(dto); + RemoveResultDto resultDto = scmConn.removeFile(dto); - if (resultDto.getFileRoot() != null) { - fileRoot = resultDto.getFileRoot(); - } if (resultDto.getScmRoot() != null) { scmRoot = resultDto.getScmRoot(); } + if (resultDto.getFileRoot() != null) { + fileRoot = resultDto.getFileRoot(); + } - if (upload == null) { - username = null; - pw = null; + if (username != null && pw != null) { + if (username.equals("") && pw.equals("")) { + username = null; + pw = null; + } } + if (resultDto.getError() != null) { String errorMessage = resultDto.getError(); error = true; - if (errorMessage.equals(UploadResultDto.CONNECTION_FAILED)) { + if (errorMessage.equals(RemoveResultDto.CONNECTION_FAILED)) { getScmSession().delScmUser(scmConn.getRepositoryId()); username = null; @@ -219,7 +188,7 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR return ERROR; - } else if (errorMessage.equals(UploadResultDto.AUTH_ERROR)) { + } else if (errorMessage.equals(RemoveResultDto.AUTH_ERROR)) { badLogin = true; username = null; @@ -228,7 +197,7 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR return LOGIN; - } else if (errorMessage.equals(UploadResultDto.REDIRECT)) { + } else if (errorMessage.equals(RemoveResultDto.REDIRECT)) { error = false; diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java index a005074..f857f4b 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/UploadAction.java @@ -81,6 +81,7 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR /** the HTTP request sent to the server */ protected transient HttpServletRequest request; + public File getUpload() { return upload; } @@ -175,6 +176,10 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR ScmConnection scmConn = provider.getConnection(address, pathToLocalRepos); // if the repository is not protected for writing, we get its UUID + if (address.endsWith("/")) { + address = address.substring(0, address.lastIndexOf('/')); + } + String repositoryUUID = scmConn.getRepositoryId(); if (repositoryUUID == null) { repositoryUUID = address.replace(' ', '_'); @@ -201,11 +206,6 @@ public class UploadAction extends AbstractScmWebEditorAction implements ServletR scmRoot = resultDto.getScmRoot(); } - if (upload == null) { - username = null; - pw = null; - } - if (resultDto.getError() != null) { String errorMessage = resultDto.getError(); diff --git a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties index 5710443..51dc3d2 100644 --- a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties +++ b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties @@ -7,10 +7,10 @@ scm.by=By scm.cannotSave=Can't save modification. scm.cantFindRepo=Can't find the repository. scm.clickHere=click here +scm.close=Close scm.commitMessage=Commit message scm.commitMessageTitle=let a message for commit scm.connection=Connection -scm.erreurRepo=Error on repository scm.exit=Exit scm.exitJavascript=Exit ScmWebEditor without saving ? All modification will be lost. scm.exitTitle=Exit ScmWebEditor without saving. @@ -47,6 +47,11 @@ scm.pathError=Path error scm.preview=Preview scm.privateScmAccess=You try to access a Private SCM. Please login scm.redirection=Redirection... +scm.remove.file=Removing file\: +scm.removeFile=Remove a file +scm.removeFileTitle=Remove a file from the repository +scm.removeSuccess=File removal successful +scm.repoError=Error on repository scm.reset=Reset scm.resetTitle=Go back to the last revision of the file scm.rstNotValidMessage=The RST is not valid, do you still want to continue ? @@ -67,7 +72,6 @@ scm.titles.success=Success scm.titles.swe=SCMWebEditor scm.titles.upload=Upload a file scm.upload=Upload -scm.upload.close=Close scm.uploadFile=File Url scm.uploadPath=Path on Repository scm.uploadSuccess=File upload successful diff --git a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties index 49696e6..8aef259 100644 --- a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties +++ b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties @@ -7,10 +7,10 @@ scm.by=Par scm.cannotSave=Modification impossible scm.cantFindRepo=Impossible de trouver le dépôt. scm.clickHere=cliquez ici +scm.close=Fermer scm.commitMessage=Message associé au commit scm.commitMessageTitle=laisser un message pour le commit scm.connection=Connexion -scm.erreurRepo=Erreur sur le dépôt scm.exit=Quitter scm.exitJavascript=Quitter ScmWebEditor sans sauvegarder ? Toutes les modifications seront perdues. scm.exitTitle=Quitter ScmWebEditor sans sauvegarder. @@ -47,6 +47,11 @@ scm.pathError=Erreur dans le chemin scm.preview=Aperçu scm.privateScmAccess=Pour modifier ce fichier, veuillez vous connecter. scm.redirection=Redirection... +scm.remove.file=Suppression du fichier \: +scm.removeFile=Supprimer un fichier +scm.removeFileTitle=Supprimer un fichier du dépôt +scm.removeSuccess=Suppression effectuée avec succès +scm.repoError=Erreur sur le dépôt scm.reset=Réinitialiser scm.resetTitle=Retour à la dernière révision du fichier scm.rstNotValidMessage=Le RST n'est pas valide, voulez-vous continuer ? @@ -67,7 +72,6 @@ scm.titles.success=Réussi scm.titles.swe=SCMWebEditor scm.titles.upload=Ajouter un fichier scm.upload=Ajouter un fichier -scm.upload.close=Fermer scm.uploadFile=Url du fichier scm.uploadPath=Répertoire sur le dépôt scm.uploadSuccess=Fichier téléchargé avec succès diff --git a/swe-ui-web/src/main/resources/struts.xml b/swe-ui-web/src/main/resources/struts.xml index 40bc0dd..087a58d 100644 --- a/swe-ui-web/src/main/resources/struts.xml +++ b/swe-ui-web/src/main/resources/struts.xml @@ -105,6 +105,13 @@ <result name="login" >/WEB-INF/content/uploadForm.jsp</result> <result name="error" >/WEB-INF/content/uploadForm.jsp</result> </action> + + <action name="doRemove" class="org.nuiton.scmwebeditor.uiweb.actions.RemoveAction"> + <result>/WEB-INF/content/removeSuccess.jsp</result> + <result name="redirect" >/WEB-INF/content/removeForm.jsp</result> + <result name="login" >/WEB-INF/content/removeForm.jsp</result> + <result name="error" >/WEB-INF/content/removeForm.jsp</result> + </action> <action name="preview" class="org.nuiton.scmwebeditor.uiweb.actions.PreviewAction"> <result>/WEB-INF/content/preview.jsp</result> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/browse.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/browse.jsp index e9c4191..27099f0 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/browse.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/browse.jsp @@ -68,7 +68,7 @@ </script> -<script src="js/pictureUpload.js" type="text/javascript"></script> +<script src="js/popup.js" type="text/javascript"></script> <s:if test="scmSupportsBranches && !error"> @@ -131,12 +131,23 @@ <s:text name="scm.uploadTitle"/> </s:set> + + <s:set id="scm.removeFile"> + <s:text name="scm.removeFile"/> + </s:set> + <s:set id="scm.removeFileTitle"> + <s:text name="scm.removeFileTitle"/> + </s:set> + <s:set name="address"> <s:property value="address"/> </s:set> <center> <s:submit name="uploadButton" value="%{scm.upload}" title="%{scm.uploadTitle}" - onClick="javascript:upload_popup('doUpload.action', 'upload' , getElementById('addressInput'), '%{scmType}' );"/> + onClick="javascript:open_popup('doUpload.action', 'upload' , getElementById('addressInput'), '%{scmType}' );"/> + + <s:submit name="removeButton" value="%{scm.removeFile}" title="%{scm.removeFileTitle}" + onClick="javascript:open_popup('doRemove.action', 'remove' , getElementById('addressInput'), '%{scmType}' );"/> </center> </s:else> 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 e4058b8..3889bf1 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 @@ -54,7 +54,7 @@ <script src="js/cancelRedirect.js" type="text/javascript"></script> - <script src="js/pictureUpload.js" type="text/javascript"></script> + <script src="js/popup.js" type="text/javascript"></script> <link rel="icon" href="img/ScmWebEditor_little.png" type="image/png"> <link rel="stylesheet" type="text/css" href="css/main.css"> @@ -428,12 +428,22 @@ <s:text name="scm.uploadTitle"/> </s:set> +<s:set id="scm.removeFile"> + <s:text name="scm.removeFile"/> +</s:set> +<s:set id="scm.removeFileTitle"> + <s:text name="scm.removeFileTitle"/> +</s:set> + <s:set name="address"> <s:property value="address"/> </s:set> <center> <s:submit name="uploadButton" value="%{scm.upload}" title="%{scm.uploadTitle}" - onClick="javascript:upload_popup('doUpload.action', 'upload' , getElementById('address'), '%{scmType}' );"/> + onClick="javascript:open_popup('doUpload.action', 'upload' , getElementById('address'), '%{scmType}' );"/> + + <s:submit name="removeButton" value="%{scm.removeFile}" title="%{scm.removeFileTitle}" + onClick="javascript:open_popup('doRemove.action', 'remove' , getElementById('address'), '%{scmType}' );"/> </center> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/removeForm.jsp similarity index 80% copy from swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp copy to swe-ui-web/src/main/webapp/WEB-INF/content/removeForm.jsp index 9211882..d22528a 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/removeForm.jsp @@ -31,7 +31,7 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <title><s:text name="scm.titles.upload"/></title> + <title><s:text name="scm.removeFile"/></title> <link rel="stylesheet" type="text/css" href="css/main.css"> <link rel="stylesheet" type="text/css" href="css/uploadForm.css"> <script type="text/javascript" src="js/branches.js"></script> @@ -43,13 +43,16 @@ <sj:head debug="true" jquerytheme="default"/> <script> + + var foo; + $.subscribe('treeClicked', function(event, data) { var item = event.originalEvent.data.rslt.obj; if (item.length == 1) { var classAttr = item[0].getAttribute("class"); - if (!classAttr.contains("jstree-leaf")) { + if (classAttr.contains("jstree-leaf")) { window.document.getElementById("scmPath").value = item.attr("id"); } } @@ -75,20 +78,16 @@ </script> -<form method="POST" id="uploadForm" action="doUpload.action" - enctype="multipart/form-data"> +<form method="POST" id="removeForm" action="doRemove.action"> <s:hidden name="scmType" value="%{scmType}"/> - <center><h1><s:text name="scm.upload"></s:text></h1></center> - - <label><s:text name="scm.uploadFile"/> : <input type="file" - name="upload"/></label><br/> - <label><s:text name="scm.uploadPath"/> : <s:textfield size="50px" type="text" - name="scmPath" - id="scmPath" - value="%{fileRoot}"/></label><br/> + <center><h1><s:text name="scm.removeFile"></s:text></h1></center> + <label><s:text name="scm.remove.file"/> <s:textfield size="50px" type="text" + name="scmPath" + id="scmPath" + value="%{fileRoot}"/></label> <div id="searchTree"> @@ -121,7 +120,7 @@ <p><font color="red"><s:text name="scm.badUsernameOrPassword"/></font></p> </s:if> <s:elseif test="error"> - <p><font color="red"><s:text name="scm.erreurRepo"/></font></p> + <p><font color="red"><s:text name="scm.repoError"/></font></p> </s:elseif> <input type="submit"/> </form> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/removeSuccess.jsp similarity index 94% copy from swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp copy to swe-ui-web/src/main/webapp/WEB-INF/content/removeSuccess.jsp index 33fa0d1..b8a8798 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/removeSuccess.jsp @@ -31,10 +31,10 @@ <title><s:text name="scm.titles.success"/></title> </head> <body> -<p><s:text name="scm.uploadSuccess"/></p> +<p><s:text name="scm.removeSuccess"/></p> <s:set id="close"> - <s:text name="scm.upload.close"/> + <s:text name="scm.close"/> </s:set> <form> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/reset.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/reset.jsp index e0a77d5..b3a2f1a 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/reset.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/reset.jsp @@ -31,7 +31,7 @@ <p><font color="red"><s:text name="scm.badUsernameOrPassword"/></font></p> </s:if> <s:elseif test="error=='errorPath'"> - <p><font color="red"><s:text name="scm.erreurRepo"/></font></p> + <p><font color="red"><s:text name="scm.repoError"/></font></p> </s:elseif> <s:else> <script type="text/javascript"> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/upload.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/upload.jsp index 8474225..8686307 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/upload.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/upload.jsp @@ -27,7 +27,7 @@ <p><font color="red"><s:text name="scm.badUsernameOrPassword"/></font></p> </s:if> <s:elseif test="error"> - <p><font color="red"><s:text name="scm.erreurRepo"/></font></p> + <p><font color="red"><s:text name="scm.repoError"/></font></p> </s:elseif> <s:else> <p><s:text name="scm.uploadSuccess"/></p> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp index 9211882..e37fbe3 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp @@ -121,7 +121,7 @@ <p><font color="red"><s:text name="scm.badUsernameOrPassword"/></font></p> </s:if> <s:elseif test="error"> - <p><font color="red"><s:text name="scm.erreurRepo"/></font></p> + <p><font color="red"><s:text name="scm.repoError"/></font></p> </s:elseif> <input type="submit"/> </form> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp index 33fa0d1..32ae236 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp @@ -34,7 +34,7 @@ <p><s:text name="scm.uploadSuccess"/></p> <s:set id="close"> - <s:text name="scm.upload.close"/> + <s:text name="scm.close"/> </s:set> <form> diff --git a/swe-ui-web/src/main/webapp/css/main.css b/swe-ui-web/src/main/webapp/css/main.css index 848f6b4..b726a7f 100644 --- a/swe-ui-web/src/main/webapp/css/main.css +++ b/swe-ui-web/src/main/webapp/css/main.css @@ -120,6 +120,18 @@ ul.flags li { display:inline; } +#wwctrl_uploadButton, #wwctrl_removeButton { + display: inline; +} + +#wwctrl_uploadButton { + margin-right: 20px; +} + +#wwctrl_removeButton { + margin-left: 20px; +} + #wwgrp_username { float:left; } diff --git a/swe-ui-web/src/main/webapp/js/pictureUpload.js b/swe-ui-web/src/main/webapp/js/popup.js similarity index 70% rename from swe-ui-web/src/main/webapp/js/pictureUpload.js rename to swe-ui-web/src/main/webapp/js/popup.js index 77f7722..343d5bb 100644 --- a/swe-ui-web/src/main/webapp/js/pictureUpload.js +++ b/swe-ui-web/src/main/webapp/js/popup.js @@ -19,8 +19,13 @@ * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% */ -function upload_popup(page, name, fileAddress, scmType) +function open_popup(page, name, fileAddress, scmType) { var address = fileAddress.value; - window.open (page+'?address='+address + '&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') + + if (!address.endsWith("/")) { + address += "/"; + } + + window.open (page+'?address=' + address + '&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') } -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm