This is an automated email from the git hooks/post-receive script. New commit to branch feature/3879 in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit 3866ee7bd7f9c5319f885a6db451acdad2d4e2e5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Feb 14 19:28:32 2016 +0100 Introduction de ScmAuthentication et utilisation de le module API --- swe-scm-api/pom.xml | 8 ++ .../nuiton/scmwebeditor/api/ScmAuthentication.java | 41 ++++++++++ .../org/nuiton/scmwebeditor/api/ScmConnection.java | 92 ++++++++++------------ .../nuiton/scmwebeditor/api/ScmFileManager.java | 27 +++++-- .../org/nuiton/scmwebeditor/api/ScmProvider.java | 57 ++++++++------ .../org/nuiton/scmwebeditor/api/dto/BrowseDto.java | 31 +------- .../org/nuiton/scmwebeditor/api/dto/CommitDto.java | 35 ++------ .../scmwebeditor/api/dto/CreateBranchDto.java | 17 +--- .../scmwebeditor/api/dto/CreateDirectoryDto.java | 29 ++----- .../nuiton/scmwebeditor/api/dto/MoveFileDto.java | 25 +----- .../scmwebeditor/api/dto/RemoveDirectoryDto.java | 29 ++----- .../nuiton/scmwebeditor/api/dto/RemoveFileDto.java | 29 ++----- .../scmwebeditor/api/dto/RequestSupport.java | 28 +++++++ .../nuiton/scmwebeditor/api/dto/UploadFileDto.java | 25 +----- 14 files changed, 200 insertions(+), 273 deletions(-) diff --git a/swe-scm-api/pom.xml b/swe-scm-api/pom.xml index e87646e..6deb964 100644 --- a/swe-scm-api/pom.xml +++ b/swe-scm-api/pom.xml @@ -12,4 +12,12 @@ <name>ScmWebEditor SCM API</name> <description>This is the core module of ScmWebEditor.</description> + + <dependencies> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + </dependencies> + </project> diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmAuthentication.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmAuthentication.java new file mode 100644 index 0000000..cafed09 --- /dev/null +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmAuthentication.java @@ -0,0 +1,41 @@ +package org.nuiton.scmwebeditor.api; + +import com.google.common.base.MoreObjects; + +/** + * A simple bean to contains login-password. + * + * Created on 14/02/16. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 0.8 + */ +public class ScmAuthentication { + + public static final ScmAuthentication ANONYMOUS = new ScmAuthentication("anonymous", "anonymous".toCharArray()); + + protected final String username; + + protected final char[] password; + + public ScmAuthentication(String username, char[] password) { + this.username = username; + this.password = password; + } + + public String getUsername() { + return username; + } + + public char[] getPassword() { + return password; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("username", username) + .add("password", "***") + .toString(); + } +} 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 ec86c13..ce322c1 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 @@ -29,6 +29,7 @@ import org.nuiton.scmwebeditor.api.dto.result.CommitResultDto; import javax.naming.AuthenticationException; import java.io.File; import java.util.Map; +import java.util.Optional; /** * An interface which gives the SCMs main features @@ -36,102 +37,95 @@ import java.util.Map; public interface ScmConnection { /** - * Searches the repository's files to make a list of them + * Searches the repository's files to make a list of them. + * * @param dto the DTO which contains all the parameters * @return a DTO which contains all the results */ BrowseResultDto browse(BrowseDto dto); - /** - * Makes a commit of the changed made to the edited file + * Makes a commit of the changed made to the edited file. + * * @param dto the DTO which contains all the parameters * @return a DTO which contains all the results */ CommitResultDto commit(CommitDto dto); - /** - * Gives the content of a file - * @param path the path to the file to get the content from - * @param username the user's login for the SCM - * @param password the user's password for the SCM + * Gives the content of a file. + * + * @param path the path to the file to get the content from + * @param optionalScmAuthentication user's authentication informations * @return a String which contains the file's content * @throws AuthenticationException if there is a problem during the authentication process */ - File getFileContent(String path, String username, String password) throws AuthenticationException; - + File getFileContent(String path, Optional<ScmAuthentication> optionalScmAuthentication) throws AuthenticationException; /** - * Gives the number of the head revision - * @param path the path to the SCM - * @param username the user's login for the SCM - * @param password the user's password for the SCM + * Gives the number of the head revision. + * + * @param path the path to the SCM + * @param optionalScmAuthentication user authentication informations * @return a String which contains the head revision's number * @throws AuthenticationException if there is a problem during the authentication process */ - String getHeadRevisionNumber(String path, String username, String password) throws AuthenticationException; - + String getHeadRevisionNumber(String path, Optional<ScmAuthentication> optionalScmAuthentication) throws AuthenticationException; /** - * Gives the repository's unique identifier + * Gives the repository's unique identifier. + * * @return the repository's unique identifier */ String getRepositoryId(); - /** - * Gives the name of the edited file + * Gives the name of the edited file. + * * @return the name of the edited file */ String getFileName(); - /** - * Gives the path to use to get a file from the repository - * @param address the full address of the file on the repository - * @param repositoryRoot the address of the repository's root - * @param username the user's login for the SCM - * @param password the user's password for the SCM + * Gives the path to use to get a file from the repository. + * + * @param address the full address of the file on the repository + * @param repositoryRoot the address of the repository's root + * @param optionalScmAuthentication user authentication informations * @return the path to use to get a file from the repository */ - String getFilePath(String address, String repositoryRoot, String username, String password); - + String getFilePath(String address, String repositoryRoot, Optional<ScmAuthentication> optionalScmAuthentication); /** - * Gives a list of the important revisions for the file at the given address - * @param address the file's address - * @param username the username to use to connect to the repository - * @param password the password to use to connect to the repository + * Gives a list of the important revisions for the file at the given address. + * + * @param address the file's address + * @param optionalScmAuthentication user authentication informations (may be null if no authentication is given) * @return a list of revisions for the file at the given address with their revision name * @throws AuthenticationException if there is a problem during the authentication process */ - Map<ScmRevision, String> getRevisions(String address, String username, String password) throws AuthenticationException; - + Map<ScmRevision, String> getRevisions(String address, Optional<ScmAuthentication> optionalScmAuthentication) throws AuthenticationException; /** - * Gives the content of a file at the specified revision - * @param path the path to the file to get the content from - * @param username the user's login for the SCM - * @param password the user's password for the SCM - * @param revision the revision ID to use to get the file content + * Gives the content of a file at the specified revision. + * + * @param path the path to the file to get the content from + * @param optionalScmAuthentication user authentication informations + * @param revision the revision ID to use to get the file content * @return a String which contains the file's content * @throws AuthenticationException if there is a problem during the authentication process */ - File getFileContentAtRevision(String path, String username, String password, String revision) - throws AuthenticationException; - + File getFileContentAtRevision(String path, Optional<ScmAuthentication> optionalScmAuthentication, String revision) throws AuthenticationException; /** - * Gives the content of a file at the specified revision - * @param path the path to the file to get the content from - * @param username the user's login for the SCM - * @param password the user's password for the SCM - * @param revision1 one of the revisions ID to compare - * @param revision2 the other revision ID to compare + * Gives the content of a file at the specified revision. + * + * @param path the path to the file to get the content from + * @param optionalScmAuthentication user authentication informations + * @param revision1 one of the revisions ID to compare + * @param revision2 the other revision ID to compare * @return a String which contains the file's content * @throws AuthenticationException if there is a problem during the authentication process */ - File getDiffs(String path, String username, String password, String revision1,String revision2) - throws AuthenticationException; + File getDiffs(String path, Optional<ScmAuthentication> optionalScmAuthentication, String revision1, String revision2) throws AuthenticationException; } diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmFileManager.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmFileManager.java index 7a5583d..f96bb7e 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmFileManager.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmFileManager.java @@ -21,8 +21,16 @@ */ package org.nuiton.scmwebeditor.api; -import org.nuiton.scmwebeditor.api.dto.*; -import org.nuiton.scmwebeditor.api.dto.result.*; +import org.nuiton.scmwebeditor.api.dto.CreateDirectoryDto; +import org.nuiton.scmwebeditor.api.dto.MoveFileDto; +import org.nuiton.scmwebeditor.api.dto.RemoveDirectoryDto; +import org.nuiton.scmwebeditor.api.dto.RemoveFileDto; +import org.nuiton.scmwebeditor.api.dto.UploadFileDto; +import org.nuiton.scmwebeditor.api.dto.result.CreateDirectoryResultDto; +import org.nuiton.scmwebeditor.api.dto.result.MoveFileResultDto; +import org.nuiton.scmwebeditor.api.dto.result.RemoveDirectoryResultDto; +import org.nuiton.scmwebeditor.api.dto.result.RemoveFileResultDto; +import org.nuiton.scmwebeditor.api.dto.result.UploadFileResultDto; /** * An interface which gives the SCMs features relative to file management @@ -30,7 +38,8 @@ import org.nuiton.scmwebeditor.api.dto.result.*; public interface ScmFileManager { /** - * Uploads a file to the repository as a new file + * Uploads a file to the repository as a new file. + * * @param dto the DTO which contains all the parameters * @return a DTO which contains all the results */ @@ -38,7 +47,8 @@ public interface ScmFileManager { /** - * Removes a file from the repository + * Removes a file from the repository. + * * @param dto the DTO which contains all the parameters * @return a DTO which contains all the results */ @@ -46,7 +56,8 @@ public interface ScmFileManager { /** - * Creates a new directory on the repository + * Creates a new directory on the repository. + * * @param dto the DTO which contains all the parameters * @return a DTO which contains all the results */ @@ -54,7 +65,8 @@ public interface ScmFileManager { /** - * Removes a directory from the repository + * Removes a directory from the repository. + * * @param dto the DTO which contains all the parameters * @return a DTO which contains all the results */ @@ -62,7 +74,8 @@ public interface ScmFileManager { /** - * Moves a file to a directory in the repository + * Moves a file to a directory in the repository. + * * @param dto the DTO which contains all the parameters * @return a DTo which contains all the results */ diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmProvider.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmProvider.java index 988128e..8105ffb 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmProvider.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmProvider.java @@ -25,6 +25,7 @@ import org.nuiton.scmwebeditor.api.dto.CreateBranchDto; import javax.naming.AuthenticationException; import java.util.List; +import java.util.Optional; /** * An interface which allows to know and to use the specific features of each SCM @@ -32,80 +33,86 @@ import java.util.List; public interface ScmProvider { /** - * Tells whether the SCM supports branches + * Tells whether the SCM supports branches. + * * @return true if the SCM supports branches */ boolean supportsBranches(); /** - * Makes a list of the repository's branches - * @param address the repository's address - * @param username the username used to connect to the SCM - * @param password the password used to connect to the SCM + * Makes a list of the repository's branches. + * + * @param address the repository's address + * @param optionalScmAuthentication user's authentication informations * @return a list of the repository's branches * @throws OperationNotSupportedException if the SCM doesn't support branches */ - List<String> listBranches(String address, String username, String password) throws OperationNotSupportedException; + List<String> listBranches(String address, Optional<ScmAuthentication> optionalScmAuthentication) throws OperationNotSupportedException; /** - * Allows to create a new branch on the repository + * Allows to create a new branch on the repository. + * * @param dto the DTO which contains all the parameters * @return an error code or null if there was no error during the process * @throws OperationNotSupportedException if the SCM doesn't support branches - * @throws AuthenticationException if there is an authentication problem - * @throws RepositoryNotFoundException if the repository could not be reached + * @throws AuthenticationException if there is an authentication problem + * @throws RepositoryNotFoundException if the repository could not be reached */ - String createBranch(CreateBranchDto dto) throws OperationNotSupportedException, - AuthenticationException, RepositoryNotFoundException; + String createBranch(CreateBranchDto dto) throws OperationNotSupportedException, AuthenticationException, RepositoryNotFoundException; /** - * Changes the working branch for the local repository - * @param branchName the new working branch - * @param pathToLocalRepos the path to the directory where the local repositories are stored - * @param username the username to use to connect to the repository - * @param password the password to use to connect to the repository + * Changes the working branch for the local repository. + * + * @param branchName the new working branch + * @param pathToLocalRepos the path to the directory where the local repositories are stored + * @param optionalScmAuthentication user's authentication informations * @return an error code or null if there was no error during the process * @throws OperationNotSupportedException if the SCM doesn't support branches */ - String changeBranch(String branchName, String pathToLocalRepos, String username, String password) - throws OperationNotSupportedException; + String changeBranch(String branchName, String pathToLocalRepos, Optional<ScmAuthentication> optionalScmAuthentication) throws OperationNotSupportedException; /** - * Tells whether the SCM allows to choose when the commits are pushed to the server + * Tells whether the SCM allows to choose when the commits are pushed to the server. + * * @return true if the SCM supports a command to push the commits to the server */ boolean supportsPush(); /** - * Tells whether the repositories' files are directly accessible by their address + * Tells whether the repositories' files are directly accessible by their address. + * * @return true if the files are directly accessible */ boolean filesDirectlyAccessible(); /** - * Gives the connection to the SCM - * @param address the repository's address + * Gives the connection to the SCM. + * + * @param address the repository's address * @param pathToLocalRepos the folder which will be used to store one client's repositories * @return the connection to the SCM */ ScmConnection getConnection(String address, String pathToLocalRepos); /** - * Gives the file manager for the given connection + * Gives the file manager for the given connection. + * * @param connection the connection to the repository * @return the file manager for the repository */ ScmFileManager getFileManager(ScmConnection connection); /** - * Tells whether the given address seems compatible with the SCM + * Tells whether the given address seems compatible with the SCM. + * * @param address the repository's address * @return true if the repository seems to be compatible with the SCM */ boolean addressSeemsCompatible(String address); /** - * Gives the name of the default branch if the SCM supports branches + * Gives the name of the default branch if the SCM supports branches. + * * @return the name of the default branch to use * @throws OperationNotSupportedException if the SCM doesn't support branches */ diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/BrowseDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/BrowseDto.java index ac9a208..b161080 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/BrowseDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/BrowseDto.java @@ -23,40 +23,17 @@ package org.nuiton.scmwebeditor.api.dto; */ -public class BrowseDto { +public class BrowseDto extends RequestSupport { - /** the username used to connect to the SCM */ - protected String username; - - /** the password used to connect to the SCM */ - protected String password; - - /** the selected branch on the SCM */ + /** Selected branch on the SCM. */ protected String selectedBranch; - /** the SCM's identifier */ + /** SCM's identifier. */ protected String id; - /** the SCM's adddress */ + /** SCM's adddress. */ protected String address; - - 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 getSelectedBranch() { return selectedBranch; } diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CommitDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CommitDto.java index 82d64da..8451b33 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CommitDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CommitDto.java @@ -22,46 +22,23 @@ package org.nuiton.scmwebeditor.api.dto; * #L% */ -public class CommitDto { +public class CommitDto extends RequestSupport{ - /** the username used to connect to the SCM */ - protected String username; - - /** the password used to connect to the SCM */ - protected String password; - - /** the new text to insert */ + /** New text to insert. */ protected String newText; - /** the message to describe the commit */ + /** Message to describe the commit. */ protected String commitMessage; - /** set to true for a commit even if there is no difference with the previous version */ + /** Set to true for a commit even if there is no difference with the previous version. */ protected boolean force; - /** the file to commit's address */ + /** File to commit's address. */ protected String address; - /** set to true for a commit without a push */ + /** Set to true for a commit without a push. */ private boolean commitOnly; - - 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 getNewText() { return newText; } diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CreateBranchDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CreateBranchDto.java index ffd4a2b..3ae9ec4 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CreateBranchDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/CreateBranchDto.java @@ -21,7 +21,7 @@ */ package org.nuiton.scmwebeditor.api.dto; -public class CreateBranchDto { +public class CreateBranchDto extends RequestSupport{ /** the repository's address */ protected String address; @@ -32,16 +32,9 @@ public class CreateBranchDto { /** the name of the origin branch for the new one */ protected String selectedBranch; - /** the username to use to connect to the repository */ - protected String username; - - /** the password to use to connect to the repository */ - protected String password; - /** the folder which is used to store the repositories */ protected String pathToLocalRepos; - public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } @@ -54,14 +47,6 @@ public class CreateBranchDto { public void setSelectedBranch(String selectedBranch) { this.selectedBranch = selectedBranch; } - 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 getPathToLocalRepos() { return pathToLocalRepos; } public void setPathToLocalRepos(String pathToLocalRepos) { this.pathToLocalRepos = pathToLocalRepos; } 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 index 9f35f07..e2fec5e 100644 --- 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 @@ -22,13 +22,7 @@ package org.nuiton.scmwebeditor.api.dto; * #L% */ -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; +public class CreateDirectoryDto extends RequestSupport{ /** the name of the directory to create */ protected String directoryName; @@ -36,27 +30,14 @@ public class CreateDirectoryDto { /** path to the repository */ protected String parentDirectory; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; + public String getDirectoryName() { + return directoryName; } - public String getPassword() { - return password; + public void setDirectoryName(String directoryName) { + this.directoryName = directoryName; } - 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; } diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/MoveFileDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/MoveFileDto.java index f78d165..1ac2957 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/MoveFileDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/MoveFileDto.java @@ -21,13 +21,7 @@ */ package org.nuiton.scmwebeditor.api.dto; -public class MoveFileDto { - - /** the username used to connect to the SCM */ - protected String username; - - /** the password used to connect to the SCM */ - protected String password; +public class MoveFileDto extends RequestSupport{ /** path to the repository */ protected String scmPath; @@ -38,23 +32,6 @@ public class MoveFileDto { /** path to the destination directory */ protected String destinationDirectory; - - 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/RemoveDirectoryDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveDirectoryDto.java index a2d0844..16ebd8b 100644 --- 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 @@ -22,35 +22,16 @@ package org.nuiton.scmwebeditor.api.dto; * #L% */ -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; +public class RemoveDirectoryDto extends RequestSupport{ /** 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 getDirectoryToRemove() { + return directoryToRemove; } - public String getPassword() { - return password; + public void setDirectoryToRemove(String directoryToRemove) { + this.directoryToRemove = directoryToRemove; } - - 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/RemoveFileDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveFileDto.java index 16697bc..b223dd9 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveFileDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RemoveFileDto.java @@ -21,35 +21,16 @@ */ package org.nuiton.scmwebeditor.api.dto; -public class RemoveFileDto { - - /** the username used to connect to the SCM */ - protected String username; - - /** the password used to connect to the SCM */ - protected String password; +public class RemoveFileDto extends RequestSupport{ /** path to the repository */ protected String scmPath; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; + public String getScmPath() { + return scmPath; } - public String getPassword() { - return password; + public void setScmPath(String scmPath) { + this.scmPath = scmPath; } - - 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/RequestSupport.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RequestSupport.java new file mode 100644 index 0000000..00d1ece --- /dev/null +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/RequestSupport.java @@ -0,0 +1,28 @@ +package org.nuiton.scmwebeditor.api.dto; + +import org.nuiton.scmwebeditor.api.ScmAuthentication; + +import java.util.Optional; + +/** + * Created on 14/02/16. + * + * @author Tony Chemit - chemit@codelutin.com + */ +public abstract class RequestSupport { + + /** user's authentication informations (or anonymous). */ + protected ScmAuthentication scmAuthentication; + + public final ScmAuthentication getScmAuthentication() { + return scmAuthentication; + } + + public final void setScmAuthentication(Optional<ScmAuthentication> optionalScmAuthentication) { + this.scmAuthentication = optionalScmAuthentication.orElse(ScmAuthentication.ANONYMOUS); + } + + public final String getUsername() { + return scmAuthentication.getUsername(); + } +} diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadFileDto.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadFileDto.java index 28abf07..500f7a7 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadFileDto.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/dto/UploadFileDto.java @@ -24,13 +24,7 @@ package org.nuiton.scmwebeditor.api.dto; import java.io.File; -public class UploadFileDto { - - /** the username used to connect to the SCM */ - protected String username; - - /** the password used to connect to the SCM */ - protected String password; +public class UploadFileDto extends RequestSupport{ /** the file to upload */ protected File upload; @@ -44,23 +38,6 @@ public class UploadFileDto { /** 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 File getUpload() { return upload; } -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.