-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d2082f
commit 311dbee
Showing
27 changed files
with
582 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 26 additions & 36 deletions
62
...er-prepare/src/main/java/com/mercedesbenz/sechub/wrapper/prepare/modules/ToolContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,52 @@ | ||
package com.mercedesbenz.sechub.wrapper.prepare.modules; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.crypto.SealedObject; | ||
|
||
public abstract class ToolContext { | ||
|
||
private static final String UPLOAD_DIRECTORY_NAME = "upload"; | ||
private String location; | ||
private String uploadDirectory; | ||
private Map<String, SealedObject> credentialMap; | ||
private Path workingDirectory; | ||
protected Path uploadDirectory; | ||
protected Path toolDownloadDirectory; | ||
|
||
private Map<String, SealedObject> credentialMap = new HashMap<>(); | ||
|
||
public void setLocation(String location) { | ||
this.location = location; | ||
} | ||
|
||
public ToolContext(ToolContextBuilder builder) { | ||
this.location = builder.location; | ||
this.uploadDirectory = builder.uploadDirectory; | ||
this.credentialMap = builder.credentialMap; | ||
public void workingDirectory(Path workingDirectory) { | ||
if (workingDirectory == null) { | ||
throw new IllegalArgumentException("Upload directory may not be null!"); | ||
} | ||
this.workingDirectory = workingDirectory; | ||
this.uploadDirectory = workingDirectory.resolve(UPLOAD_DIRECTORY_NAME); | ||
} | ||
|
||
public void setCredentialMap(Map<String, SealedObject> credentialMap) { | ||
this.credentialMap = credentialMap; | ||
} | ||
|
||
public String getLocation() { | ||
return location; | ||
} | ||
|
||
public String getUploadDirectory() { | ||
public Path getUploadDirectory() { | ||
return uploadDirectory; | ||
} | ||
|
||
public Map<String, SealedObject> getCredentialMap() { | ||
return Collections.unmodifiableMap(credentialMap); | ||
} | ||
|
||
public abstract static class ToolContextBuilder { | ||
private String location; | ||
private String uploadDirectory; | ||
private Map<String, SealedObject> credentialMap = new HashMap<>(); | ||
|
||
public abstract ToolContext build(); | ||
|
||
public ToolContextBuilder setLocation(String location) { | ||
if (location == null || location.isEmpty()) { | ||
throw new IllegalArgumentException("Defined Location must not be null or empty."); | ||
} | ||
this.location = location; | ||
return this; | ||
} | ||
|
||
public ToolContextBuilder setUploadDirectory(String uploadDirectory) { | ||
if (uploadDirectory == null || uploadDirectory.isEmpty()) { | ||
throw new IllegalArgumentException("Defined PDS Prepare Upload Directory must not be null or empty."); | ||
} | ||
this.uploadDirectory = uploadDirectory; | ||
return this; | ||
} | ||
|
||
public ToolContextBuilder setCredentialMap(Map<String, SealedObject> credentialMap) { | ||
if (!(credentialMap == null)) { | ||
this.credentialMap = credentialMap; | ||
} | ||
return this; | ||
} | ||
public Path getToolDownloadDirectory() { | ||
return toolDownloadDirectory; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 18 additions & 28 deletions
46
...prepare/src/main/java/com/mercedesbenz/sechub/wrapper/prepare/modules/git/GitContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,34 @@ | ||
package com.mercedesbenz.sechub.wrapper.prepare.modules.git; | ||
|
||
import java.nio.file.Path; | ||
|
||
import com.mercedesbenz.sechub.wrapper.prepare.modules.ToolContext; | ||
|
||
public class GitContext extends ToolContext { | ||
private boolean cloneWithoutHistory; | ||
|
||
private String filename; | ||
static final String DOWNLOAD_DIRECTORY_NAME = "git-download"; | ||
private boolean cloneWithoutHistory; | ||
private String repositoryName = "git-repository"; | ||
|
||
private GitContext(GitContextBuilder builder) { | ||
super(builder); | ||
this.cloneWithoutHistory = builder.cloneWithoutHistory; | ||
this.filename = builder.filename; | ||
public void setCloneWithoutHistory(boolean cloneWithoutHistory) { | ||
this.cloneWithoutHistory = cloneWithoutHistory; | ||
} | ||
|
||
public boolean isCloneWithoutHistory() { | ||
return cloneWithoutHistory; | ||
public void setWorkingDirectory(Path workingDirectory) { | ||
super.workingDirectory(workingDirectory); | ||
toolDownloadDirectory = workingDirectory.resolve(DOWNLOAD_DIRECTORY_NAME); | ||
} | ||
|
||
public String getFilename() { | ||
return filename; | ||
public String getRepositoryName() { | ||
return repositoryName; | ||
} | ||
|
||
public static class GitContextBuilder extends ToolContextBuilder { | ||
private boolean cloneWithoutHistory = true; | ||
|
||
private String filename = "GitDownloadDirectory"; | ||
|
||
public GitContextBuilder setCloneWithoutHistory(boolean cloneWithoutHistory) { | ||
this.cloneWithoutHistory = cloneWithoutHistory; | ||
return this; | ||
} | ||
|
||
public GitContextBuilder setFilename(String filename) { | ||
this.filename = filename; | ||
return this; | ||
} | ||
public void setRepositoryName(String repositoryName) { | ||
this.repositoryName = repositoryName; | ||
} | ||
|
||
@Override | ||
public GitContext build() { | ||
return new GitContext(this); | ||
} | ||
public boolean isCloneWithoutHistory() { | ||
return cloneWithoutHistory; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.