Skip to content
Snippets Groups Projects
Commit e568cd51 authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Merge branch 'malowe/master/65' into 'master'

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

See merge request !82
parents 19d9fa5a ae0b3fb9
No related branches found
No related tags found
Loading
Pipeline #5697 passed
...@@ -15,6 +15,7 @@ import java.util.stream.Collectors; ...@@ -15,6 +15,7 @@ import java.util.stream.Collectors;
import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.MultivaluedMap;
import org.eclipsefoundation.git.eca.model.Commit; 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.model.ValidationRequest;
import org.eclipsefoundation.git.eca.namespace.GitEcaParameterNames; import org.eclipsefoundation.git.eca.namespace.GitEcaParameterNames;
import org.jboss.resteasy.specimpl.MultivaluedMapImpl; import org.jboss.resteasy.specimpl.MultivaluedMapImpl;
...@@ -63,10 +64,22 @@ public class CommitHelper { ...@@ -63,10 +64,22 @@ public class CommitHelper {
public static MultivaluedMap<String, String> getCommitParams(List<String> commitShas, String projectId, String repoUrl) { public static MultivaluedMap<String, String> getCommitParams(List<String> commitShas, String projectId, String repoUrl) {
MultivaluedMap<String, String> params = new MultivaluedMapImpl<>(); MultivaluedMap<String, String> params = new MultivaluedMapImpl<>();
params.put(GitEcaParameterNames.SHAS_RAW, commitShas); params.put(GitEcaParameterNames.SHAS_RAW, commitShas);
params.add(GitEcaParameterNames.PROJECT_ID_RAW, projectId);
params.add(GitEcaParameterNames.REPO_URL_RAW, repoUrl); params.add(GitEcaParameterNames.REPO_URL_RAW, repoUrl);
if (projectId != null) {
params.add(GitEcaParameterNames.PROJECT_ID_RAW, projectId);
}
return params; 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() { private CommitHelper() {
} }
......
...@@ -71,7 +71,7 @@ public class DefaultValidationService implements ValidationService { ...@@ -71,7 +71,7 @@ public class DefaultValidationService implements ValidationService {
List<CommitValidationStatus> statuses, Project p) { List<CommitValidationStatus> statuses, Project p) {
// remove existing messaging // remove existing messaging
RDBMSQuery<CommitValidationMessage> q = new RDBMSQuery<>(wrapper, filters.get(CommitValidationMessage.class), RDBMSQuery<CommitValidationMessage> q = new RDBMSQuery<>(wrapper, filters.get(CommitValidationMessage.class),
CommitHelper.getCommitParams(req, p != null ? p.getProjectId() : null)); CommitHelper.getCommitParams(req, CommitHelper.getProjectId(p)));
List<CommitValidationMessage> messages = new ArrayList<>(); List<CommitValidationMessage> messages = new ArrayList<>();
List<CommitValidationStatus> updatedStatuses = new ArrayList<>(); List<CommitValidationStatus> updatedStatuses = new ArrayList<>();
...@@ -88,7 +88,7 @@ public class DefaultValidationService implements ValidationService { ...@@ -88,7 +88,7 @@ public class DefaultValidationService implements ValidationService {
base = status.get(); base = status.get();
} else { } else {
base = new CommitValidationStatus(); base = new CommitValidationStatus();
base.setProject(p != null ? p.getProjectId() : null); base.setProject(CommitHelper.getProjectId(p));
base.setCommitHash(e.getKey()); base.setCommitHash(e.getKey());
base.setProvider(req.getProvider()); base.setProvider(req.getProvider());
base.setRepoUrl(req.getRepoUrl().toString()); base.setRepoUrl(req.getRepoUrl().toString());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment