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

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

parent 9eff7663
No related branches found
No related tags found
1 merge request!82Iss. #65 - Fix error caused by no project match in validation req
......@@ -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) {
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() {
}
......
......@@ -71,7 +71,7 @@ public class DefaultValidationService implements ValidationService {
List<CommitValidationStatus> statuses, Project p) {
// remove existing messaging
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<CommitValidationStatus> updatedStatuses = new ArrayList<>();
......@@ -88,7 +88,7 @@ public class DefaultValidationService implements ValidationService {
base = status.get();
} else {
base = new CommitValidationStatus();
base.setProject(p != null ? p.getProjectId() : null);
base.setProject(CommitHelper.getProjectId(p));
base.setCommitHash(e.getKey());
base.setProvider(req.getProvider());
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