Skip to content
Snippets Groups Projects

Iss. #65 - Fix error caused by no project match in validation req

Merged Iss. #65 - Fix error caused by no project match in validation req
1 unresolved thread
Merged Martin Lowe requested to merge (removed):malowe/master/65 into master
1 unresolved thread
2 files
+ 16
3
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -15,6 +15,7 @@ import java.util.stream.Collectors;
import javax.ws.rs.core.MultivaluedMap;
import org.eclipsefoundation.git.eca.model.Commit;
import org.eclipsefoundation.git.eca.model.Project;
import org.eclipsefoundation.git.eca.model.ValidationRequest;
import org.eclipsefoundation.git.eca.namespace.GitEcaParameterNames;
import org.jboss.resteasy.specimpl.MultivaluedMapImpl;
@@ -63,10 +64,22 @@ public class CommitHelper {
public static MultivaluedMap<String, String> getCommitParams(List<String> commitShas, String projectId, String repoUrl) {
MultivaluedMap<String, String> params = new MultivaluedMapImpl<>();
params.put(GitEcaParameterNames.SHAS_RAW, commitShas);
params.add(GitEcaParameterNames.PROJECT_ID_RAW, projectId);
params.add(GitEcaParameterNames.REPO_URL_RAW, repoUrl);
if (projectId != null) {
    • why not making Project#getProjectId returning an Optional<String> instead? It would prevent forgetting from calling the CommitHelper#getProjectId static method.

      • Author Maintainer

        I did it that way so that downstream wouldn't need to know that the default is never null. This way if its null, it passes back empty string.

      • Please register or sign in to reply
Please register or sign in to reply
params.add(GitEcaParameterNames.PROJECT_ID_RAW, projectId);
}
return params;
}
/**
* Centralized way of retrieving a checked project ID from a project for use when interacting with commits and commit data.
*
* @param p the current project to attempt to retrieve an ID from
* @return the project ID or the given default (empty string).
*/
public static String getProjectId(Project p) {
return p != null ? p.getProjectId() : "";
}
private CommitHelper() {
}
Loading