branch develop updated (aa460ff -> 76dc73e)
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 aa460ff Add loading indicators when browsing a repository and when saving the changes new 76dc73e Add the ability to create a new directory in 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 76dc73eda904d351a20d3ea7f7ba0fc1788a2d4f Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Wed May 27 17:32:09 2015 +0200 Add the ability to create a new directory in the repository Summary of changes: .../org/nuiton/scmwebeditor/git/GitConnection.java | 168 ++++++++++++++++++++- .../org/nuiton/scmwebeditor/api/ScmConnection.java | 2 + .../scmwebeditor/api/dto/CreateDirectoryDto.java | 45 ++++++ ...esultDto.java => CreateDirectoryResultDto.java} | 2 +- .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 92 ++++++++++- ...emoveAction.java => CreateDirectoryAction.java} | 46 +++--- .../i18n/scmwebeditor-ui-web_en_GB.properties | 9 +- .../i18n/scmwebeditor-ui-web_fr_FR.properties | 7 + swe-ui-web/src/main/resources/struts.xml | 34 +++-- .../src/main/webapp/WEB-INF/content/browse.jsp | 11 +- .../webapp/WEB-INF/content/modificationViewer.jsp | 14 +- .../content/{ => popups}/createBranchForm.jsp | 0 .../content/{ => popups}/createBranchSuccess.jsp | 0 .../createDirectoryForm.jsp} | 19 ++- .../createDirectorySuccess.jsp} | 4 +- .../WEB-INF/content/{ => popups}/removeForm.jsp | 0 .../WEB-INF/content/{ => popups}/removeSuccess.jsp | 0 .../WEB-INF/content/{ => popups}/uploadForm.jsp | 0 .../WEB-INF/content/{ => popups}/uploadSuccess.jsp | 0 swe-ui-web/src/main/webapp/css/main.css | 11 +- 20 files changed, 395 insertions(+), 69 deletions(-) create mode 100644 swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CreateDirectoryDto.java copy swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/{UploadResultDto.java => CreateDirectoryResultDto.java} (95%) copy swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/{RemoveAction.java => CreateDirectoryAction.java} (79%) rename swe-ui-web/src/main/webapp/WEB-INF/content/{ => popups}/createBranchForm.jsp (100%) rename swe-ui-web/src/main/webapp/WEB-INF/content/{ => popups}/createBranchSuccess.jsp (100%) copy swe-ui-web/src/main/webapp/WEB-INF/content/{uploadForm.jsp => popups/createDirectoryForm.jsp} (83%) copy swe-ui-web/src/main/webapp/WEB-INF/content/{removeSuccess.jsp => popups/createDirectorySuccess.jsp} (96%) rename swe-ui-web/src/main/webapp/WEB-INF/content/{ => popups}/removeForm.jsp (100%) rename swe-ui-web/src/main/webapp/WEB-INF/content/{ => popups}/removeSuccess.jsp (100%) rename swe-ui-web/src/main/webapp/WEB-INF/content/{ => popups}/uploadForm.jsp (100%) rename swe-ui-web/src/main/webapp/WEB-INF/content/{ => popups}/uploadSuccess.jsp (100%) -- 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 76dc73eda904d351a20d3ea7f7ba0fc1788a2d4f Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Wed May 27 17:32:09 2015 +0200 Add the ability to create a new directory in the repository --- .../org/nuiton/scmwebeditor/git/GitConnection.java | 168 ++++++++++++++- .../org/nuiton/scmwebeditor/api/ScmConnection.java | 2 + .../scmwebeditor/api/dto/CreateDirectoryDto.java | 45 ++++ .../api/dto/result/CreateDirectoryResultDto.java | 51 +++++ .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 92 ++++++++- .../uiweb/actions/CreateDirectoryAction.java | 226 +++++++++++++++++++++ .../i18n/scmwebeditor-ui-web_en_GB.properties | 9 +- .../i18n/scmwebeditor-ui-web_fr_FR.properties | 7 + swe-ui-web/src/main/resources/struts.xml | 34 ++-- .../src/main/webapp/WEB-INF/content/browse.jsp | 11 +- .../webapp/WEB-INF/content/modificationViewer.jsp | 14 +- .../content/{ => popups}/createBranchForm.jsp | 0 .../content/{ => popups}/createBranchSuccess.jsp | 0 .../createDirectoryForm.jsp} | 19 +- .../createDirectorySuccess.jsp} | 2 +- .../WEB-INF/content/{ => popups}/removeForm.jsp | 0 .../WEB-INF/content/{ => popups}/removeSuccess.jsp | 0 .../WEB-INF/content/{ => popups}/uploadForm.jsp | 0 .../WEB-INF/content/{ => popups}/uploadSuccess.jsp | 0 swe-ui-web/src/main/webapp/css/main.css | 11 +- 20 files changed, 643 insertions(+), 48 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 e152c4b..f47c38f 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 @@ -39,14 +39,8 @@ import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.eclipse.jgit.treewalk.TreeWalk; import org.nuiton.scmwebeditor.api.RepositoryNotFoundException; import org.nuiton.scmwebeditor.api.ScmConnection; -import org.nuiton.scmwebeditor.api.dto.BrowseDto; -import org.nuiton.scmwebeditor.api.dto.CommitDto; -import org.nuiton.scmwebeditor.api.dto.RemoveDto; -import org.nuiton.scmwebeditor.api.dto.UploadDto; -import org.nuiton.scmwebeditor.api.dto.result.BrowseResultDto; -import org.nuiton.scmwebeditor.api.dto.result.CommitResultDto; -import org.nuiton.scmwebeditor.api.dto.result.RemoveResultDto; -import org.nuiton.scmwebeditor.api.dto.result.UploadResultDto; +import org.nuiton.scmwebeditor.api.dto.*; +import org.nuiton.scmwebeditor.api.dto.result.*; import javax.naming.AuthenticationException; import java.io.File; @@ -729,6 +723,164 @@ public class GitConnection implements ScmConnection { return resultDto; } + @Override + public CreateDirectoryResultDto createDirectory(CreateDirectoryDto dto) { + + CreateDirectoryResultDto resultDto = new CreateDirectoryResultDto(); + + // 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(UploadResultDto.ERROR); + return resultDto; + + } catch (IOException e) { + + if (log.isErrorEnabled()) { + log.error("Error while cloning or pulling the repository", e); + } + resultDto.setError(UploadResultDto.ERROR); + return resultDto; + + } catch (AuthenticationException e) { + + if (log.isErrorEnabled()) { + log.error("Error while cloning or pulling the repository", e); + } + resultDto.setError(UploadResultDto.AUTH_ERROR); + return resultDto; + } + + resultDto.setFileRoot(addressGit); + resultDto.setScmRoot(addressGit); + + // if the name of the new directory is empty we get back to the create directory form + if (dto.getDirectoryName() == null) { + + resultDto.setError(UploadResultDto.REDIRECT); + return resultDto; + } + + if (dto.getDirectoryName().equals("")) { + + resultDto.setError(UploadResultDto.REDIRECT); + return resultDto; + } + + // Creating the new directory in the local directory + String pathOnRepo = dto.getParentDirectory(); + + if (pathOnRepo.length() > addressGit.length()) { + pathOnRepo = pathOnRepo.substring(addressGit.length() + 1); + } else { + pathOnRepo = ""; + } + + File file = new File(localDirectory.getAbsolutePath() + File.separator + pathOnRepo + + File.separator + dto.getDirectoryName()); + file.mkdir(); + File emptyFile = new File(file.getAbsolutePath() + File.separator + ".gitignore"); + + try { + emptyFile.createNewFile(); + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Can not create file '" + emptyFile.getAbsolutePath() + "'"); + } + } + + // 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); + + // add + AddCommand add = git.add(); + String toAdd; + + if (pathOnRepo.equals("")) { + toAdd = dto.getDirectoryName() + "/.gitignore"; + } else { + toAdd = pathOnRepo + "/" + dto.getDirectoryName() + "/.gitignore"; + } + + add.addFilepattern(toAdd); + + try { + add.call(); + } catch (GitAPIException e) { + if (log.isErrorEnabled()) { + log.error("Can not add new files", e); + } + } + + // commit + try { + doCommit(git, dto.getUsername(), "unknown", "From scmwebeditor -- create the directory : " + dto.getDirectoryName()); + } catch (GitAPIException e) { + if (log.isErrorEnabled()) { + log.error("Can not commit", e); + } + + resultDto.setError(UploadResultDto.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) { + + emptyFile.delete(); + file.delete(); + + handlePushException(e); + + 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); + } + + emptyFile.delete(); + file.delete(); + resultDto.setError(UploadResultDto.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 8f16989..935d836 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,6 +63,8 @@ public interface ScmConnection { */ RemoveResultDto removeFile(RemoveDto dto); + CreateDirectoryResultDto createDirectory(CreateDirectoryDto dto); + /** * Gives the content of a file as a String diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CreateDirectoryDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CreateDirectoryDto.java new file mode 100644 index 0000000..056a1ad --- /dev/null +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CreateDirectoryDto.java @@ -0,0 +1,45 @@ +package org.nuiton.scmwebeditor.api.dto; + +public class CreateDirectoryDto { + + /** the username used to connect to the SCM */ + protected String username; + + /** the password used to connect to the SCM */ + protected String password; + + /** the name of the directory to create */ + protected String directoryName; + + /** path to the repository */ + protected String parentDirectory; + + + 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 getDirectoryName() { return directoryName; } + + public void setDirectoryName(String directoryName) { this.directoryName = directoryName; } + + public String getParentDirectory() { + return parentDirectory; + } + + public void setParentDirectory(String parentDirectory) { + this.parentDirectory = parentDirectory; + } +} diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/CreateDirectoryResultDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/CreateDirectoryResultDto.java new file mode 100644 index 0000000..33fcccb --- /dev/null +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/result/CreateDirectoryResultDto.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 CreateDirectoryResultDto 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 7aec0aa..1c9455d 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 @@ -25,14 +25,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.scmwebeditor.api.ScmConnection; -import org.nuiton.scmwebeditor.api.dto.BrowseDto; -import org.nuiton.scmwebeditor.api.dto.CommitDto; -import org.nuiton.scmwebeditor.api.dto.RemoveDto; -import org.nuiton.scmwebeditor.api.dto.UploadDto; -import org.nuiton.scmwebeditor.api.dto.result.BrowseResultDto; -import org.nuiton.scmwebeditor.api.dto.result.CommitResultDto; -import org.nuiton.scmwebeditor.api.dto.result.RemoveResultDto; -import org.nuiton.scmwebeditor.api.dto.result.UploadResultDto; +import org.nuiton.scmwebeditor.api.dto.*; +import org.nuiton.scmwebeditor.api.dto.result.*; import org.nuiton.util.FileUtil; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; @@ -572,6 +566,88 @@ public class SvnConnection implements ScmConnection { return resultDto; } + @Override + public CreateDirectoryResultDto createDirectory(CreateDirectoryDto dto) { + + CreateDirectoryResultDto resultDto = new CreateDirectoryResultDto(); + + 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 new directory is empty we get back to the create directory form + if (dto.getDirectoryName() == null) { + + resultDto.setError(UploadResultDto.REDIRECT); + return resultDto; + } + + if (dto.getDirectoryName().equals("")) { + + resultDto.setError(UploadResultDto.REDIRECT); + return resultDto; + } + + SVNCommitClient commitClient = new SVNCommitClient(manager, svnOption); + + try { + SVNURL[] urls = new SVNURL[1]; + urls[0] = SVNURL.parseURIEncoded(dto.getParentDirectory() + "/" + dto.getDirectoryName()); + + commitClient.doMkDir(urls, "From scmwebeditor -- create the directory : " + dto.getDirectoryName()); + } 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/CreateDirectoryAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/CreateDirectoryAction.java new file mode 100644 index 0000000..7d37297 --- /dev/null +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/CreateDirectoryAction.java @@ -0,0 +1,226 @@ +/* + * #%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.result.CreateDirectoryResultDto; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.io.File; + +/** + * Creates a new directory in the repository + */ +public class CreateDirectoryAction extends AbstractScmWebEditorAction implements ServletRequestAware { + + private static final long serialVersionUID = 4244339447567114412L; + + private static final Log log = LogFactory.getLog(CreateDirectoryAction.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 URL the root of the repository */ + protected String scmRoot; + + /** the name of the directory to create */ + protected String directoryName; + + /** the full path of the parent directory for the new one */ + protected String parentDirectory; + + /** equals true if there is a problem during the authentication process */ + protected boolean badLogin; + + /** equals true if an error occurs */ + protected boolean error; + + /** 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 getScmRoot() { + return scmRoot; + } + + public void setScmRoot(String scmRoot) { this.scmRoot = scmRoot; } + + 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 getDirectoryName() { return directoryName; } + + public void setDirectoryName(String directoryName) { this.directoryName = directoryName; } + + public String getParentDirectory() { return parentDirectory; } + + public void setParentDirectory(String parentDirectory) { this.parentDirectory = parentDirectory; } + + /** + * Execution of the create 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]; + + CreateDirectoryDto dto = new CreateDirectoryDto(); + dto.setUsername(username); + dto.setPassword(pw); + dto.setDirectoryName(directoryName); + dto.setParentDirectory(parentDirectory); + + CreateDirectoryResultDto resultDto = scmConn.createDirectory(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(CreateDirectoryResultDto.CONNECTION_FAILED)) { + + getScmSession().delScmUser(scmConn.getRepositoryId()); + username = null; + pw = null; + + return ERROR; + + } else if (errorMessage.equals(CreateDirectoryResultDto.AUTH_ERROR)) { + + badLogin = true; + username = null; + pw = null; + getScmSession().delScmUser(scmConn.getRepositoryId()); + + return LOGIN; + + } else if (errorMessage.equals(CreateDirectoryResultDto.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 d2acfda..3030a08 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 @@ -16,6 +16,9 @@ scm.createBranch=Create a new branch scm.createBranch.branchName=Name of the new branch\: scm.createBranch.originBranch=Original branch for the new branch\: 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.exit=Exit scm.exitJavascript=Exit ScmWebEditor? scm.exitJavascriptChanges=Exit ScmWebEditor without saving? All modification will be lost. @@ -26,7 +29,7 @@ scm.formTransferred=You should be transferred automatically to the form page. If scm.info.ProblemWithRst=For any problem with RestructuredText visit scm.info.rstWebsite=RST documentation website scm.language=Language -scm.lastChangeSave=Last change save +scm.lastChangeSave=Last change save scm.logAs=You are log as \: scm.loginButton=Login scm.logoutWait=Logout... @@ -39,6 +42,7 @@ scm.modificationViewer.previewPosition.below=Below scm.modificationViewer.previewPosition.none=No preview scm.modificationViewer.previewPosition.side=On the side scm.mustBeLog=You must be login to see this repository. +scm.newDirectoryName=Name of the new directory\: scm.no=No scm.outConnection.branches=List of branches scm.outConnection.enterRepo=Please enter your repository address. @@ -48,6 +52,7 @@ scm.outConnection.scmPath=SCM path \: scm.outConnection.scmType=Use the SCM\: scm.outConnection.search=Search scm.outConnection.selectBranch=Select a branch\: +scm.parentDirectory=Parent directory\: scm.password=Password scm.passwordTitle=Repository password scm.pathError=Path error @@ -55,6 +60,8 @@ scm.preview=Preview 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.removeDirectoryTitle=Remove a directory from the repository scm.removeFile=Remove a file scm.removeFileTitle=Remove a file from the repository scm.removeSuccess=File removal 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 f5ada72..04d6b21 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 @@ -16,6 +16,9 @@ scm.createBranch=Créer une nouvelle branche scm.createBranch.branchName=Nom de la nouvelle branche \: scm.createBranch.originBranch=Branche d'origine pour la nouvelle branche \: 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.exit=Quitter scm.exitJavascript=Quitter ScmWebEditor ? scm.exitJavascriptChanges=Quitter ScmWebEditor sans sauvegarder ? Toutes les modifications seront perdues. @@ -39,6 +42,7 @@ scm.modificationViewer.previewPosition.below=En dessous scm.modificationViewer.previewPosition.none=Pas d'aperçu scm.modificationViewer.previewPosition.side=Sur le côté scm.mustBeLog=Vous devez vous identifier pour parcourir ce dépôt. +scm.newDirectoryName=Nom du nouveau répertoire \: scm.no=Non scm.outConnection.branches=Liste des branches scm.outConnection.enterRepo=Entrez l'adresse de votre dépôt. @@ -48,6 +52,7 @@ scm.outConnection.scmPath=Répertoire SCM \: scm.outConnection.scmType=Utiliser le SCM \: scm.outConnection.search=Chercher scm.outConnection.selectBranch=Sélectionner une branche \: +scm.parentDirectory=Répertoire parent \: scm.password=Mot de passe scm.passwordTitle=Mot de passe du dépôt scm.pathError=Erreur dans le chemin @@ -55,6 +60,8 @@ scm.preview=Aperçu 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.removeDirectoryTitle=Supprimer un répertoire du dépôt scm.removeFile=Supprimer un fichier scm.removeFileTitle=Supprimer un fichier du dépôt scm.removeSuccess=Suppression effectuée avec succès diff --git a/swe-ui-web/src/main/resources/struts.xml b/swe-ui-web/src/main/resources/struts.xml index 3e2e6b5..fc28d40 100644 --- a/swe-ui-web/src/main/resources/struts.xml +++ b/swe-ui-web/src/main/resources/struts.xml @@ -86,8 +86,7 @@ </action> <action name="save" class="org.nuiton.scmwebeditor.uiweb.actions.SaveAction"> - <result name="success">/WEB-INF/content/save.jsp</result> - <result name="prepareCommit">/WEB-INF/content/commitForm.jsp</result> + <result>/WEB-INF/content/save.jsp</result> </action> <action name="reset" class="org.nuiton.scmwebeditor.uiweb.actions.ResetAction"> @@ -101,24 +100,31 @@ </action> <action name="doUpload" class="org.nuiton.scmwebeditor.uiweb.actions.UploadAction"> - <result>/WEB-INF/content/uploadSuccess.jsp</result> - <result name="redirect" >/WEB-INF/content/uploadForm.jsp</result> - <result name="login" >/WEB-INF/content/uploadForm.jsp</result> - <result name="error" >/WEB-INF/content/uploadForm.jsp</result> + <result>/WEB-INF/content/popups/uploadSuccess.jsp</result> + <result name="redirect" >/WEB-INF/content/popups/uploadForm.jsp</result> + <result name="login" >/WEB-INF/content/popups/uploadForm.jsp</result> + <result name="error" >/WEB-INF/content/popups/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> + <result>/WEB-INF/content/popups/removeSuccess.jsp</result> + <result name="redirect" >/WEB-INF/content/popups/removeForm.jsp</result> + <result name="login" >/WEB-INF/content/popups/removeForm.jsp</result> + <result name="error" >/WEB-INF/content/popups/removeForm.jsp</result> + </action> + + <action name="doCreateDirectory" class="org.nuiton.scmwebeditor.uiweb.actions.CreateDirectoryAction"> + <result>/WEB-INF/content/popups/createDirectorySuccess.jsp</result> + <result name="redirect" >/WEB-INF/content/popups/createDirectoryForm.jsp</result> + <result name="login" >/WEB-INF/content/popups/createDirectoryForm.jsp</result> + <result name="error" >/WEB-INF/content/popups/createDirectoryForm.jsp</result> </action> <action name="createBranch" class="org.nuiton.scmwebeditor.uiweb.actions.CreateBranchAction"> - <result name="success">/WEB-INF/content/createBranchSuccess.jsp</result> - <result name="redirect">/WEB-INF/content/createBranchForm.jsp</result> - <result name="login">/WEB-INF/content/createBranchForm.jsp</result> - <result name="error">/WEB-INF/content/createBranchForm.jsp</result> + <result name="success">/WEB-INF/content/popups/createBranchSuccess.jsp</result> + <result name="redirect">/WEB-INF/content/popups/createBranchForm.jsp</result> + <result name="login">/WEB-INF/content/popups/createBranchForm.jsp</result> + <result name="error">/WEB-INF/content/popups/createBranchForm.jsp</result> </action> <action name="preview" class="org.nuiton.scmwebeditor.uiweb.actions.PreviewAction"> 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 fe50a0a..1324161 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 @@ -144,7 +144,6 @@ <s:text name="scm.uploadTitle"/> </s:set> - <s:set id="scm.removeFile"> <s:text name="scm.removeFile"/> </s:set> @@ -152,6 +151,13 @@ <s:text name="scm.removeFileTitle"/> </s:set> + <s:set id="scm.createDirectory"> + <s:text name="scm.createDirectory"/> + </s:set> + <s:set id="scm.createDirectoryTitle"> + <s:text name="scm.createDirectoryTitle"/> + </s:set> + <s:set name="address"> <s:property value="address"/> </s:set> @@ -161,6 +167,9 @@ <s:submit name="removeButton" value="%{scm.removeFile}" title="%{scm.removeFileTitle}" onClick="javascript:open_popup('doRemove.action', 'remove' , scmAddress, '%{scmType}' );"/> + + <s:submit name="createDirectoryButton" value="%{scm.createDirectory}" title="%{scm.createDirectoryTitle}" + onClick="javascript:open_popup('doCreateDirectory.action', 'create 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 6dd5dc9..2413e74 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 @@ -407,16 +407,26 @@ <s:text name="scm.removeFileTitle"/> </s:set> + <s:set id="scm.createDirectory"> + <s:text name="scm.createDirectory"/> + </s:set> + <s:set id="scm.createDirectoryTitle"> + <s:text name="scm.createDirectoryTitle"/> + </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:open_popup('doUpload.action', 'upload' , getElementById('address').value, '%{scmType}' );"/> + onClick="javascript:open_popup('doUpload.action', 'upload', getElementById('address').value, '%{scmType}');"/> <s:submit name="removeButton" value="%{scm.removeFile}" title="%{scm.removeFileTitle}" - onClick="javascript:open_popup('doRemove.action', 'remove' , getElementById('address').value, '%{scmType}' );"/> + onClick="javascript:open_popup('doRemove.action', 'remove', getElementById('address').value, '%{scmType}');"/> + + <s:submit name="createDirectoryButton" value="%{scm.createDirectory}" title="%{scm.createDirectoryTitle}" + onClick="javascript:open_popup('doCreateDirectory.action', 'create directory',getElementById('address').value,'%{scmType}');"/> </center> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/createBranchForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createBranchForm.jsp similarity index 100% rename from swe-ui-web/src/main/webapp/WEB-INF/content/createBranchForm.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/createBranchForm.jsp diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/createBranchSuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createBranchSuccess.jsp similarity index 100% rename from swe-ui-web/src/main/webapp/WEB-INF/content/createBranchSuccess.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/createBranchSuccess.jsp diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectoryForm.jsp similarity index 83% copy from swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp copy to swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectoryForm.jsp index f383145..9f04c8b 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectoryForm.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.createDirectory"/></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"> @@ -51,7 +51,7 @@ var classAttr = item[0].getAttribute("class"); if (!classAttr.contains("jstree-leaf")) { - window.document.getElementById("scmPath").value = item.attr("id"); + window.document.getElementById("parentDirectory").value = item.attr("id"); } } @@ -76,20 +76,19 @@ </script> -<form method="POST" id="uploadForm" action="doUpload.action" +<form method="POST" id="createDirectoryForm" action="doCreateDirectory.action" enctype="multipart/form-data"> <s:hidden name="scmType" value="%{scmType}"/> - <center><h1><s:text name="scm.upload"></s:text></h1></center> + <center><h1><s:text name="scm.createDirectory"></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/> + <label><s:text name="scm.newDirectoryName"/> <input type="text" name="directoryName" id="directoryName"/> + </label><br/> + <label><s:text name="scm.parentDirectory"/> <s:textfield size="50px" type="text" name="parentDirectory" + id="parentDirectory" value="%{fileRoot}"/> + </label><br/> <div id="searchTree"> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectorySuccess.jsp similarity index 96% copy from swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp copy to swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectorySuccess.jsp index 6c91195..76440ac 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectorySuccess.jsp @@ -38,7 +38,7 @@ </head> <body> -<p><s:text name="scm.uploadSuccess"/></p> +<p><s:text name="scm.createDirectorySuccess"/></p> <s:set id="close"> <s:text name="scm.close"/> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/removeForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeForm.jsp similarity index 100% rename from swe-ui-web/src/main/webapp/WEB-INF/content/removeForm.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeForm.jsp diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/removeSuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeSuccess.jsp similarity index 100% rename from swe-ui-web/src/main/webapp/WEB-INF/content/removeSuccess.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/removeSuccess.jsp diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadForm.jsp similarity index 100% rename from swe-ui-web/src/main/webapp/WEB-INF/content/uploadForm.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadForm.jsp diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadSuccess.jsp similarity index 100% rename from swe-ui-web/src/main/webapp/WEB-INF/content/uploadSuccess.jsp rename to swe-ui-web/src/main/webapp/WEB-INF/content/popups/uploadSuccess.jsp diff --git a/swe-ui-web/src/main/webapp/css/main.css b/swe-ui-web/src/main/webapp/css/main.css index 1bff934..7d02f7e 100644 --- a/swe-ui-web/src/main/webapp/css/main.css +++ b/swe-ui-web/src/main/webapp/css/main.css @@ -125,16 +125,21 @@ ul.flags li { display:inline; } -#wwctrl_uploadButton, #wwctrl_removeButton { +#wwctrl_uploadButton, #wwctrl_removeButton, #wwctrl_createDirectoryButton { display: inline; } #wwctrl_uploadButton { - margin-right: 20px; + margin-right: 1%; } #wwctrl_removeButton { - margin-left: 20px; + margin-left: 1%; + margin-right: 1%; +} + +#wwctrl_createDirectoryButton { + margin-left: 1%; } #wwgrp_username { -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm