branch develop updated (76dc73e -> 7bbd807)
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 76dc73e Add the ability to create a new directory in the repository new 7bbd807 Add the ability to remove a directory from the 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 7bbd80792c82fa81a1bfe69ab6f381278d1961e5 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Thu May 28 10:08:51 2015 +0200 Add the ability to remove a directory from the repository Summary of changes: .../org/nuiton/scmwebeditor/git/GitConnection.java | 145 +++++++++++++++++++++ .../org/nuiton/scmwebeditor/api/ScmConnection.java | 14 ++ .../scmwebeditor/api/dto/RemoveDirectoryDto.java | 34 +++++ ...esultDto.java => RemoveDirectoryResultDto.java} | 2 +- .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 82 ++++++++++++ ...ctoryAction.java => RemoveDirectoryAction.java} | 50 ++++--- .../i18n/scmwebeditor-ui-web_en_GB.properties | 2 + .../i18n/scmwebeditor-ui-web_fr_FR.properties | 2 + swe-ui-web/src/main/resources/struts.xml | 7 + .../src/main/webapp/WEB-INF/content/browse.jsp | 10 ++ .../webapp/WEB-INF/content/modificationViewer.jsp | 10 ++ ...teDirectoryForm.jsp => removeDirectoryForm.jsp} | 15 +-- ...emoveSuccess.jsp => removeDirectorySuccess.jsp} | 4 +- swe-ui-web/src/main/webapp/css/main.css | 6 +- 14 files changed, 340 insertions(+), 43 deletions(-) create mode 100644 swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDirectoryDto.java copy swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/{CreateDirectoryResultDto.java => RemoveDirectoryResultDto.java} (95%) copy swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/{CreateDirectoryAction.java => RemoveDirectoryAction.java} (82%) copy swe-ui-web/src/main/webapp/WEB-INF/content/popups/{createDirectoryForm.jsp => removeDirectoryForm.jsp} (85%) copy swe-ui-web/src/main/webapp/WEB-INF/content/popups/{removeSuccess.jsp => removeDirectorySuccess.jsp} (96%) -- 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 7bbd80792c82fa81a1bfe69ab6f381278d1961e5 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Thu May 28 10:08:51 2015 +0200 Add the ability to remove a directory from the repository --- .../org/nuiton/scmwebeditor/git/GitConnection.java | 145 ++++++++++++++ .../org/nuiton/scmwebeditor/api/ScmConnection.java | 14 ++ .../scmwebeditor/api/dto/RemoveDirectoryDto.java | 34 ++++ .../api/dto/result/RemoveDirectoryResultDto.java | 51 +++++ .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 82 ++++++++ .../uiweb/actions/RemoveDirectoryAction.java | 220 +++++++++++++++++++++ .../i18n/scmwebeditor-ui-web_en_GB.properties | 2 + .../i18n/scmwebeditor-ui-web_fr_FR.properties | 2 + swe-ui-web/src/main/resources/struts.xml | 7 + .../src/main/webapp/WEB-INF/content/browse.jsp | 10 + .../webapp/WEB-INF/content/modificationViewer.jsp | 10 + .../WEB-INF/content/popups/removeDirectoryForm.jsp | 127 ++++++++++++ .../content/popups/removeDirectorySuccess.jsp | 51 +++++ swe-ui-web/src/main/webapp/css/main.css | 6 +- 14 files changed, 758 insertions(+), 3 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 f47c38f..6d28959 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 @@ -881,6 +881,151 @@ public class GitConnection implements ScmConnection { return resultDto; } + @Override + public RemoveDirectoryResultDto removeDirectory(RemoveDirectoryDto dto) { + + RemoveDirectoryResultDto resultDto = new RemoveDirectoryResultDto(); + + // getting the last version of the repository + 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.getDirectoryToRemove() == null) { + resultDto.setError(RemoveResultDto.REDIRECT); + return resultDto; + } + if (dto.getDirectoryToRemove().equals("") || dto.getDirectoryToRemove().equals(addressGit)) { + resultDto.setError(RemoveResultDto.REDIRECT); + return resultDto; + } + + // Removing the directory from the local directory + String pathOnRepo = dto.getDirectoryToRemove(); + + if (pathOnRepo.length() > addressGit.length()) { + pathOnRepo = pathOnRepo.replace(addressGit + "/", ""); + } + + File directory = 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 directory + RmCommand rm = git.rm(); + rm.addFilepattern(pathOnRepo); + try { + rm.call(); + } catch (GitAPIException e) { + if (log.isErrorEnabled()) { + log.error("Can not remove Git remove " + pathOnRepo, e); + } + + resultDto.setError(RemoveResultDto.ERROR); + return resultDto; + } + directory.delete(); + + // commit + try { + doCommit(git, dto.getUsername(), "unknown", "From scmwebeditor -- remove the directory : " + pathOnRepo); + } catch (GitAPIException e) { + if (log.isErrorEnabled()) { + log.error("Can not commit", e); + } + + resultDto.setError(RemoveResultDto.ERROR); + return resultDto; + } + + // push + if (log.isDebugEnabled()) { + log.debug("Preparing push"); + } + + PushCommand push = git.push(); + push.setRemote(addressGit); + push.setCredentialsProvider(credentials); + + try { + push.call(); + } catch (GitAPIException e) { + + handlePushException(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); + } + } + + if (e.getMessage().endsWith("not authorized")) { + resultDto.setError(RemoveResultDto.AUTH_ERROR); + } else { + resultDto.setError(RemoveResultDto.ERROR); + } + + return resultDto; + } + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Can not open git local repository : " + localDirectory.getAbsolutePath(), e); + } + + resultDto.setError(RemoveResultDto.ERROR); + return resultDto; + } + + return resultDto; + } + @Override public File getFileContent(String path, String username, String password) throws AuthenticationException { 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 935d836..682c57e 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 @@ -63,10 +63,24 @@ public interface ScmConnection { */ RemoveResultDto removeFile(RemoveDto dto); + + /** + * Creates a new directory on the repository + * @param dto the DTO which contains all the parameters + * @return a DTO which contains all the results + */ CreateDirectoryResultDto createDirectory(CreateDirectoryDto dto); /** + * Removes a directory from the repository + * @param dto the DTO which contains all the parameters + * @return a DTO which contains all the results + */ + RemoveDirectoryResultDto removeDirectory(RemoveDirectoryDto 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 diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDirectoryDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDirectoryDto.java new file mode 100644 index 0000000..931cab6 --- /dev/null +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDirectoryDto.java @@ -0,0 +1,34 @@ +package org.nuiton.scmwebeditor.api.dto; + +public class RemoveDirectoryDto { + + /** the username used to connect to the SCM */ + protected String username; + + /** the password used to connect to the SCM */ + protected String password; + + /** the path to the directory to remove */ + protected String directoryToRemove; + + + 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 getDirectoryToRemove() { return directoryToRemove; } + + public void setDirectoryToRemove(String directoryToRemove) { this.directoryToRemove = directoryToRemove; } +} diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveDirectoryResultDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveDirectoryResultDto.java new file mode 100644 index 0000000..702529c --- /dev/null +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/RemoveDirectoryResultDto.java @@ -0,0 +1,51 @@ +/* + * #%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.result; + +public class RemoveDirectoryResultDto extends AbstractResultDto { + + public static String REDIRECT = "redirect"; + + public static String CONNECTION_FAILED = "connection failed"; + + /** the directory which contains the file */ + protected String fileRoot; + + /** the root direcory of the repository */ + protected String scmRoot; + + public String getFileRoot() { + return fileRoot; + } + + public void setFileRoot(String fileRoot) { + this.fileRoot = fileRoot; + } + + public String getScmRoot() { + return scmRoot; + } + + public void setScmRoot(String scmRoot) { + this.scmRoot = 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 1c9455d..64e65dc 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 @@ -648,6 +648,88 @@ public class SvnConnection implements ScmConnection { return resultDto; } + @Override + public RemoveDirectoryResultDto removeDirectory(RemoveDirectoryDto dto) { + + RemoveDirectoryResultDto resultDto = new RemoveDirectoryResultDto(); + + if (dto.getUsername() == null) { + dto.setUsername("anonymous"); + } + + if (dto.getPassword() == null) { + dto.setPassword("anonymous"); + } + + resultDto.setScmRoot(getSvnRoot(dto.getUsername(), dto.getPassword())); + + 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 { + testConnection(); + } catch (SVNException e) { + if (log.isDebugEnabled()) { + log.debug("Test connection fail", e); + } + + resultDto.setError(UploadResultDto.CONNECTION_FAILED); + return resultDto; + } + + + // if the name of the directory to remove is empty we get back to the remove directory form + if (dto.getDirectoryToRemove() == null) { + + resultDto.setError(UploadResultDto.REDIRECT); + return resultDto; + } + + if (dto.getDirectoryToRemove().equals("") || dto.getDirectoryToRemove().equals(resultDto.getFileRoot())) { + + resultDto.setError(UploadResultDto.REDIRECT); + return resultDto; + } + + SVNCommitClient commitClient = new SVNCommitClient(manager, svnOption); + + try { + SVNURL[] urls = new SVNURL[1]; + urls[0] = SVNURL.parseURIEncoded(dto.getDirectoryToRemove()); + + commitClient.doDelete(urls, "From scmwebeditor -- remove the directory : " + dto.getDirectoryToRemove()); + } catch (SVNAuthenticationException authexep) { + + if (log.isErrorEnabled()) { + log.error("authentication fail", authexep); + } + resultDto.setError(UploadResultDto.AUTH_ERROR); + + return resultDto; + + } catch (SVNException e) { + + if (log.isErrorEnabled()) { + log.error("Error SVN import", e); + } + resultDto.setError(UploadResultDto.ERROR); + + return resultDto; + + } + + return resultDto; + } + @Override public File getFileContent(String path, String username, String password) throws AuthenticationException { diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveDirectoryAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveDirectoryAction.java new file mode 100644 index 0000000..c8d697a --- /dev/null +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/RemoveDirectoryAction.java @@ -0,0 +1,220 @@ +/* + * #%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.uiweb.actions; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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.CreateDirectoryDto; +import org.nuiton.scmwebeditor.api.dto.RemoveDirectoryDto; +import org.nuiton.scmwebeditor.api.dto.result.CreateDirectoryResultDto; +import org.nuiton.scmwebeditor.api.dto.result.RemoveDirectoryResultDto; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.io.File; + +/** + * Removes a directory on the repository + */ +public class RemoveDirectoryAction extends AbstractScmWebEditorAction implements ServletRequestAware { + + private static final long serialVersionUID = 4244339447567114412L; + + private static final Log log = LogFactory.getLog(RemoveDirectoryAction.class); + + public static final String REDIRECT = "redirect"; + + /** the username to use to connect to the repository */ + protected String username; + + /** the password to use to connect to the repository */ + protected String pw; + + /** the repository's address */ + protected String address; + + /** the path to the directory to remove */ + protected String directoryToRemove; + + /** equals true if there is a problem during the authentication process */ + protected boolean badLogin; + + /** equals true if an error occurs */ + protected boolean error; + + /** the URL the root of the repository */ + protected String scmRoot; + + /** the HTTP request sent to the server */ + protected transient HttpServletRequest request; + + /** the full path of the file to remove */ + protected String fileRoot; + + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPw() { + return pw; + } + + public void setPw(String pw) { + this.pw = pw; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getAddress() { + return address; + } + + public boolean isBadLogin() { + return badLogin; + } + + public boolean isError() { + return error; + } + + public String getDirectoryToRemove() { + return directoryToRemove; + } + + public void setDirectoryToRemove(String directoryToRemove) { this.directoryToRemove = directoryToRemove; } + + public void setBadLogin(boolean badLogin) { this.badLogin = badLogin; } + + public void setError(boolean error) { this.error = error; } + + public HttpServletRequest getRequest() { return request; } + + public String getFileRoot() { return fileRoot; } + + public void setFileRoot(String fileRoot) { this.fileRoot = fileRoot; } + + public String getScmRoot() { return scmRoot; } + + public void setScmRoot(String scmRoot) { this.scmRoot = scmRoot; } + + /** + * Execution of the remove directory action + * @return a code interpreted in the file struts.xml + */ + public String execute() { + + HttpSession session = request.getSession(); + String sessionId = session.getId(); + String pathToLocalRepos = ScmWebEditorConfig.getLocalRepositoriesPath() + File.separator + sessionId; + + ScmProvider provider = ScmWebEditorConfig.getProvider(scmType); + + 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(' ', '_'); + } + + String[] usernamePw = getUsernamePwFromSession(repositoryUUID, username, pw); + username = usernamePw[0]; + pw = usernamePw[1]; + + RemoveDirectoryDto dto = new RemoveDirectoryDto(); + dto.setUsername(username); + dto.setPassword(pw); + dto.setDirectoryToRemove(directoryToRemove); + + RemoveDirectoryResultDto resultDto = scmConn.removeDirectory(dto); + + if (resultDto.getScmRoot() != null) { + scmRoot = resultDto.getScmRoot(); + } + if (resultDto.getFileRoot() != null) { + fileRoot = resultDto.getFileRoot(); + } + + 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(RemoveDirectoryResultDto.CONNECTION_FAILED)) { + + getScmSession().delScmUser(scmConn.getRepositoryId()); + username = null; + pw = null; + + return ERROR; + + } else if (errorMessage.equals(RemoveDirectoryResultDto.AUTH_ERROR)) { + + badLogin = true; + username = null; + pw = null; + getScmSession().delScmUser(scmConn.getRepositoryId()); + + return LOGIN; + + } else if (errorMessage.equals(RemoveDirectoryResultDto.REDIRECT)) { + + error = false; + + return REDIRECT; + } else { + + return ERROR; + } + } + + return SUCCESS; + } + + @Override + public void setServletRequest(HttpServletRequest request) { + this.request = request; + } +} 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 3030a08..fe67464 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 @@ -19,6 +19,7 @@ scm.createBranchSuccess=Branch successfully created scm.createDirectory=Create a directory scm.createDirectorySuccess=Directory created successfully scm.createDirectoryTitle=Create a new directory on the repository +scm.directoryToRemove=Directory to remove\: scm.exit=Exit scm.exitJavascript=Exit ScmWebEditor? scm.exitJavascriptChanges=Exit ScmWebEditor without saving? All modification will be lost. @@ -61,6 +62,7 @@ scm.privateScmAccess=You try to access a Private SCM. Please login scm.redirection=Redirection... scm.remove.file=Removing file\: scm.removeDirectory=Remove a directory +scm.removeDirectorySuccess=Directory removal successful scm.removeDirectoryTitle=Remove a directory from the repository scm.removeFile=Remove a file scm.removeFileTitle=Remove a file from the repository 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 04d6b21..ede494a 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 @@ -19,6 +19,7 @@ scm.createBranchSuccess=Branche créée avec succès scm.createDirectory=Créer un répertoire scm.createDirectorySuccess=Répertoire créé avec succès scm.createDirectoryTitle=Créer un nouveau répertoire sur le dépôt +scm.directoryToRemove=Répertoire à supprimer \: scm.exit=Quitter scm.exitJavascript=Quitter ScmWebEditor ? scm.exitJavascriptChanges=Quitter ScmWebEditor sans sauvegarder ? Toutes les modifications seront perdues. @@ -61,6 +62,7 @@ scm.privateScmAccess=Pour modifier ce fichier, veuillez vous connecter. scm.redirection=Redirection... scm.remove.file=Suppression du fichier \: scm.removeDirectory=Supprimer un répertoire +scm.removeDirectorySuccess=Répertoire supprimé avec succès scm.removeDirectoryTitle=Supprimer un répertoire du dépôt scm.removeFile=Supprimer un fichier scm.removeFileTitle=Supprimer un fichier du dépôt diff --git a/swe-ui-web/src/main/resources/struts.xml b/swe-ui-web/src/main/resources/struts.xml index fc28d40..78449d5 100644 --- a/swe-ui-web/src/main/resources/struts.xml +++ b/swe-ui-web/src/main/resources/struts.xml @@ -120,6 +120,13 @@ <result name="error" >/WEB-INF/content/popups/createDirectoryForm.jsp</result> </action> + <action name="doRemoveDirectory" class="org.nuiton.scmwebeditor.uiweb.actions.RemoveDirectoryAction"> + <result>/WEB-INF/content/popups/removeDirectorySuccess.jsp</result> + <result name="redirect" >/WEB-INF/content/popups/removeDirectoryForm.jsp</result> + <result name="login" >/WEB-INF/content/popups/removeDirectoryForm.jsp</result> + <result name="error" >/WEB-INF/content/popups/removeDirectoryForm.jsp</result> + </action> + <action name="createBranch" class="org.nuiton.scmwebeditor.uiweb.actions.CreateBranchAction"> <result name="success">/WEB-INF/content/popups/createBranchSuccess.jsp</result> <result name="redirect">/WEB-INF/content/popups/createBranchForm.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 1324161..eb913b1 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 @@ -158,6 +158,13 @@ <s:text name="scm.createDirectoryTitle"/> </s:set> + <s:set id="scm.removeDirectory"> + <s:text name="scm.removeDirectory"/> + </s:set> + <s:set id="scm.removeDirectoryTitle"> + <s:text name="scm.removeDirectoryTitle"/> + </s:set> + <s:set name="address"> <s:property value="address"/> </s:set> @@ -170,6 +177,9 @@ <s:submit name="createDirectoryButton" value="%{scm.createDirectory}" title="%{scm.createDirectoryTitle}" onClick="javascript:open_popup('doCreateDirectory.action', 'create directory',scmAddress,'%{scmType}');"/> + + <s:submit name="removeDirectoryButton" value="%{scm.removeDirectory}" title="%{scm.removeDirectoryTitle}" + onClick="javascript:open_popup('doRemoveDirectory.action', 'remove directory',scmAddress,'%{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 2413e74..fe3509d 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 @@ -414,6 +414,13 @@ <s:text name="scm.createDirectoryTitle"/> </s:set> + <s:set id="scm.removeDirectory"> + <s:text name="scm.removeDirectory"/> + </s:set> + <s:set id="scm.removeDirectoryTitle"> + <s:text name="scm.removeDirectoryTitle"/> + </s:set> + <s:set name="address"> <s:property value="address"/> </s:set> @@ -427,6 +434,9 @@ <s:submit name="createDirectoryButton" value="%{scm.createDirectory}" title="%{scm.createDirectoryTitle}" onClick="javascript:open_popup('doCreateDirectory.action', 'create directory',getElementById('address').value,'%{scmType}');"/> + + <s:submit name="removeDirectoryButton" value="%{scm.removeDirectory}" title="%{scm.removeDirectoryTitle}" + onClick="javascript:open_popup('doRemoveDirectory.action', 'remove directory',getElementById('address').value,'%{scmType}');"/> </center> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeDirectoryForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeDirectoryForm.jsp new file mode 100644 index 0000000..2afe41f --- /dev/null +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeDirectoryForm.jsp @@ -0,0 +1,127 @@ +<%-- + #%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% + --%> + +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8" %> + +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sj" uri="/struts-jquery-tags" %> +<%@ taglib prefix="sjt" uri="/struts-jquery-tree-tags" %> + +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title><s:text name="scm.removeDirectory"/></title> + <link rel="stylesheet" type="text/css" href="css/main.css"> + <link rel="stylesheet" type="text/css" href="css/uploadForm.css"> + <link rel="icon" href="img/machine-a-ecrire_little.png" type="image/png"> + <script type="text/javascript" src="js/branches.js"></script> + + +</head> +<body> + +<sj:head debug="true" jquerytheme="default"/> + +<script> + $.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")) { + window.document.getElementById("directoryToRemove").value = item.attr("id"); + } + } + + }); + + // automatically expand the directory when there is no other file + $.subscribe('treeChanged', function(event, data) { + + var json = event.originalEvent.data.responseJSON; + + if (json.length == 1) { + var object = json[0]; + + if (object.title.startsWith('/')) { + var htmlObject = document.getElementById(object.id); + var children = htmlObject.children; + children.item('ins').click(); + } + } + }); + +</script> + + +<form method="POST" id="removeDirectoryForm" action="doRemoveDirectory.action" + enctype="multipart/form-data"> + + <s:hidden name="scmType" value="%{scmType}"/> + + <center><h1><s:text name="scm.removeDirectory"></s:text></h1></center> + + <label><s:text name="scm.directoryToRemove"/> <s:textfield size="50px" type="text" name="directoryToRemove" + id="directoryToRemove" value="%{fileRoot}"/> + </label><br/> + + <div id="searchTree"> + + <s:url id="searchTreeUrl" + action="browse?address=%{scmRoot}&username=%{username}&pw=%{pw}&selectedBranch=%{selectedBranch}&scmType=%{scmType}"/> + <sjt:tree id="scmTree" + htmlTitles="true" + jstreetheme="classic" + href="%{searchTreeUrl}" + onClickTopics="treeClicked" + onSuccessTopics="treeChanged" + /> + + </div> + + + <s:if test="username==null || pw==null"> + <label><s:text name="scm.username"/> : <input type="text" name="username"/></label><br/> + <label><s:text name="scm.password"/> : <input type="password" + name="pw"/></label><br/> + </s:if> + + <s:else> + <s:text name="scm.logAs"/> <s:property value="username"/> <br/> + </s:else> + + + <s:hidden key="address"/> + <s:if test="badLogin"> + <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.repoError"/></font></p> + </s:elseif> + <input type="submit"/> +</form> + +</body> +</html> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeDirectorySuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeDirectorySuccess.jsp new file mode 100644 index 0000000..5846f8f --- /dev/null +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeDirectorySuccess.jsp @@ -0,0 +1,51 @@ +<%-- + #%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% + --%> + +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <link rel="stylesheet" type="text/css" href="css/main.css"> + <link rel="icon" href="img/machine-a-ecrire_little.png" type="image/png"> + <script type="text/javascript" src="js/popup.js"></script> + <title><s:text name="scm.titles.success"/></title> + + <script type="text/javascript"> + window.onbeforeunload = close_popup; + </script> + +</head> +<body> +<p><s:text name="scm.removeDirectorySuccess"/></p> + +<s:set id="close"> + <s:text name="scm.close"/> +</s:set> + +<form> + <s:submit type="button" value="%{close}" onclick="window.close()"/> +</form> +</body> +</html> diff --git a/swe-ui-web/src/main/webapp/css/main.css b/swe-ui-web/src/main/webapp/css/main.css index 7d02f7e..16816ee 100644 --- a/swe-ui-web/src/main/webapp/css/main.css +++ b/swe-ui-web/src/main/webapp/css/main.css @@ -125,7 +125,7 @@ ul.flags li { display:inline; } -#wwctrl_uploadButton, #wwctrl_removeButton, #wwctrl_createDirectoryButton { +#wwctrl_uploadButton, #wwctrl_removeButton, #wwctrl_createDirectoryButton, #wwctrl_removeDirectoryButton { display: inline; } @@ -133,12 +133,12 @@ ul.flags li { margin-right: 1%; } -#wwctrl_removeButton { +#wwctrl_removeButton, #wwctrl_createDirectoryButton { margin-left: 1%; margin-right: 1%; } -#wwctrl_createDirectoryButton { +#wwctrl_removeDirectoryButton { margin-left: 1%; } -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm