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

Merge branch 'zacharysabourin/master/73' into 'master'

feat: Update copyright headers on all Java files

Closes #73

See merge request eclipsefdn/it/api/git-eca-rest-api!99
parents 63b9d5dd 082d5d8b
No related branches found
No related tags found
1 merge request!99feat: Update copyright headers on all Java files
Pipeline #9377 failed
Showing
with 347 additions and 221 deletions
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.api; package org.eclipsefoundation.git.eca.api;
import java.util.List; import java.util.List;
...@@ -23,9 +25,10 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; ...@@ -23,9 +25,10 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import org.eclipsefoundation.git.eca.model.EclipseUser; import org.eclipsefoundation.git.eca.model.EclipseUser;
/** /**
* Binding interface for the Eclipse Foundation user account API. Runtime implementations are automatically generated by * Binding interface for the Eclipse Foundation user account API. Runtime
* Quarkus at compile time. As the API deals with sensitive information, authentication is required to access this * implementations are automatically generated by
* endpoint. * Quarkus at compile time. As the API deals with sensitive information,
* authentication is required to access this endpoint.
* *
* @author Martin Lowe * @author Martin Lowe
* *
...@@ -49,7 +52,8 @@ public interface AccountsAPI { ...@@ -49,7 +52,8 @@ public interface AccountsAPI {
* Retrieves user objects that matches the given Github username. * Retrieves user objects that matches the given Github username.
* *
* @param authBearer authorization header value for validating call * @param authBearer authorization header value for validating call
* @param uname username of the Github account to retrieve Eclipse Account for * @param uname username of the Github account to retrieve Eclipse Account
* for
* @return the matching Eclipse account or null * @return the matching Eclipse account or null
*/ */
@GET @GET
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.api; package org.eclipsefoundation.git.eca.api;
import java.util.List; import java.util.List;
...@@ -30,7 +32,7 @@ import com.fasterxml.jackson.databind.JsonNode; ...@@ -30,7 +32,7 @@ import com.fasterxml.jackson.databind.JsonNode;
@Path("/bots") @Path("/bots")
@RegisterRestClient @RegisterRestClient
public interface BotsAPI { public interface BotsAPI {
/** /**
* Retrieves all bot users from the endpoint. * Retrieves all bot users from the endpoint.
* *
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2022 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.api; package org.eclipsefoundation.git.eca.api;
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ApplicationScoped;
...@@ -18,6 +20,7 @@ import javax.ws.rs.core.Response; ...@@ -18,6 +20,7 @@ import javax.ws.rs.core.Response;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import org.eclipsefoundation.core.service.APIMiddleware.BaseAPIParameters; import org.eclipsefoundation.core.service.APIMiddleware.BaseAPIParameters;
import org.jboss.resteasy.annotations.GZIP; import org.jboss.resteasy.annotations.GZIP;
/** /**
* Interface for interacting with the PMI Projects API. Used to link Git * Interface for interacting with the PMI Projects API. Used to link Git
* repos/projects with an Eclipse project to validate committer access. * repos/projects with an Eclipse project to validate committer access.
......
/*********************************************************************
* Copyright (c) 2022 Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.config; package org.eclipsefoundation.git.eca.config;
import java.util.List; import java.util.List;
...@@ -26,7 +37,8 @@ public class EclipseQuteTemplateExtensions { ...@@ -26,7 +37,8 @@ public class EclipseQuteTemplateExtensions {
} }
/** /**
* Formats and flattens a list of statuses to a list of errors encountered while validation a set of commits. * Formats and flattens a list of statuses to a list of errors encountered while
* validation a set of commits.
* *
* @param statuses a list of commit validation statuses to retrieve errors from * @param statuses a list of commit validation statuses to retrieve errors from
* @return a list of flattened errors, or an empty list if (none are found. * @return a list of flattened errors, or an empty list if (none are found.
...@@ -37,8 +49,9 @@ public class EclipseQuteTemplateExtensions { ...@@ -37,8 +49,9 @@ public class EclipseQuteTemplateExtensions {
/** /**
* <p> * <p>
* Obfuscates an email for public consumption, showing the first letter of the email address, and the domain of the * Obfuscates an email for public consumption, showing the first letter of the
* address for identification, and stripping out the rest of the address. * email address, and the domain of the address for identification, and
* stripping out the rest of the address.
* </p> * </p>
* *
* <p> * <p>
...@@ -48,7 +61,8 @@ public class EclipseQuteTemplateExtensions { ...@@ -48,7 +61,8 @@ public class EclipseQuteTemplateExtensions {
* </p> * </p>
* *
* @param email the address to obfuscate * @param email the address to obfuscate
* @return the obfuscated address, or empty string if (the string could not be parsed as an email address. * @return the obfuscated address, or empty string if (the string could not be
* parsed as an email address.
*/ */
static String obfuscateEmail(String email) { static String obfuscateEmail(String email) {
Matcher m = EMAIL_OBFUSCATION_PATTERN.matcher(email); Matcher m = EMAIL_OBFUSCATION_PATTERN.matcher(email);
...@@ -56,7 +70,8 @@ public class EclipseQuteTemplateExtensions { ...@@ -56,7 +70,8 @@ public class EclipseQuteTemplateExtensions {
} }
/** /**
* Standardized conversion of error codes into messages to be consumed downstream. * Standardized conversion of error codes into messages to be consumed
* downstream.
* *
* @param message the validation error to convert into a meaningful message * @param message the validation error to convert into a meaningful message
* @return the message string for the given validation error. * @return the message string for the given validation error.
......
/*********************************************************************
* Copyright (c) 2022 Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.dto; package org.eclipsefoundation.git.eca.dto;
import java.util.List; import java.util.List;
......
/*********************************************************************
* Copyright (c) 2022 Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.dto; package org.eclipsefoundation.git.eca.dto;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
...@@ -41,7 +52,7 @@ public class CommitValidationStatus extends BareNode { ...@@ -41,7 +52,7 @@ public class CommitValidationStatus extends BareNode {
private ProviderType provider; private ProviderType provider;
private ZonedDateTime creationDate; private ZonedDateTime creationDate;
private ZonedDateTime lastModified; private ZonedDateTime lastModified;
@OneToMany(mappedBy = "commit", fetch = FetchType.EAGER,cascade = { CascadeType.ALL }, orphanRemoval = true) @OneToMany(mappedBy = "commit", fetch = FetchType.EAGER, cascade = { CascadeType.ALL }, orphanRemoval = true)
private List<CommitValidationMessage> errors; private List<CommitValidationMessage> errors;
@Override @Override
...@@ -186,7 +197,8 @@ public class CommitValidationStatus extends BareNode { ...@@ -186,7 +197,8 @@ public class CommitValidationStatus extends BareNode {
String commitHash = params.getFirst(GitEcaParameterNames.SHA.getName()); String commitHash = params.getFirst(GitEcaParameterNames.SHA.getName());
if (StringUtils.isNumeric(commitHash)) { if (StringUtils.isNumeric(commitHash)) {
stmt.addClause( stmt.addClause(
new ParameterizedSQLStatement.Clause(TABLE.getAlias() + ".commitHash = ?", new Object[] { commitHash })); new ParameterizedSQLStatement.Clause(TABLE.getAlias() + ".commitHash = ?",
new Object[] { commitHash }));
} }
String projectId = params.getFirst(GitEcaParameterNames.PROJECT_ID.getName()); String projectId = params.getFirst(GitEcaParameterNames.PROJECT_ID.getName());
if (StringUtils.isNumeric(projectId)) { if (StringUtils.isNumeric(projectId)) {
...@@ -196,7 +208,8 @@ public class CommitValidationStatus extends BareNode { ...@@ -196,7 +208,8 @@ public class CommitValidationStatus extends BareNode {
List<String> commitHashes = params.get(GitEcaParameterNames.SHAS.getName()); List<String> commitHashes = params.get(GitEcaParameterNames.SHAS.getName());
if (commitHashes != null && !commitHashes.isEmpty()) { if (commitHashes != null && !commitHashes.isEmpty()) {
stmt.addClause( stmt.addClause(
new ParameterizedSQLStatement.Clause(TABLE.getAlias() + ".commitHash IN ?", new Object[] { commitHashes })); new ParameterizedSQLStatement.Clause(TABLE.getAlias() + ".commitHash IN ?",
new Object[] { commitHashes }));
} }
String repoUrl = params.getFirst(GitEcaParameterNames.REPO_URL.getName()); String repoUrl = params.getFirst(GitEcaParameterNames.REPO_URL.getName());
if (StringUtils.isNotBlank(repoUrl)) { if (StringUtils.isNotBlank(repoUrl)) {
......
/*********************************************************************
* Copyright (c) 2022 Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.dto; package org.eclipsefoundation.git.eca.dto;
import java.io.Serializable; import java.io.Serializable;
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.helper; package org.eclipsefoundation.git.eca.helper;
import java.util.List; import java.util.List;
...@@ -61,7 +63,8 @@ public class CommitHelper { ...@@ -61,7 +63,8 @@ public class CommitHelper {
req.getRepoUrl().toString()); req.getRepoUrl().toString());
} }
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.REPO_URL_RAW, repoUrl); params.add(GitEcaParameterNames.REPO_URL_RAW, repoUrl);
...@@ -70,9 +73,10 @@ public class CommitHelper { ...@@ -70,9 +73,10 @@ public class CommitHelper {
} }
return params; return params;
} }
/** /**
* Centralized way of retrieving a checked project ID from a project for use when interacting with commits and commit data. * 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 * @param p the current project to attempt to retrieve an ID from
* @return the project ID or the given default (empty string). * @return the project ID or the given default (empty string).
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.model; package org.eclipsefoundation.git.eca.model;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -27,25 +29,25 @@ import com.google.auto.value.AutoValue; ...@@ -27,25 +29,25 @@ import com.google.auto.value.AutoValue;
@AutoValue @AutoValue
@JsonDeserialize(builder = AutoValue_Commit.Builder.class) @JsonDeserialize(builder = AutoValue_Commit.Builder.class)
public abstract class Commit { public abstract class Commit {
@Nullable @Nullable
public abstract String getHash(); public abstract String getHash();
@Nullable @Nullable
public abstract String getSubject(); public abstract String getSubject();
@Nullable @Nullable
public abstract String getBody(); public abstract String getBody();
@Nullable @Nullable
public abstract List<String> getParents(); public abstract List<String> getParents();
@Nullable @Nullable
public abstract GitUser getAuthor(); public abstract GitUser getAuthor();
@Nullable @Nullable
public abstract GitUser getCommitter(); public abstract GitUser getCommitter();
@Nullable @Nullable
public abstract Boolean getHead(); public abstract Boolean getHead();
public static Builder builder() { public static Builder builder() {
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.model; package org.eclipsefoundation.git.eca.model;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -19,7 +21,8 @@ import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; ...@@ -19,7 +21,8 @@ import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
/** /**
* Contains information generated about a commit that was submitted for validation to the API. * Contains information generated about a commit that was submitted for
* validation to the API.
* *
* @author Martin Lowe * @author Martin Lowe
* *
......
/** /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* <p>This program and the accompanying materials are made available under the terms of the Eclipse * This program and the accompanying materials are made
* Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/ * available under the terms of the Eclipse Public License 2.0
* * which is available at https://www.eclipse.org/legal/epl-2.0/
* <p>SPDX-License-Identifier: EPL-2.0 *
*/ * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.model; package org.eclipsefoundation.git.eca.model;
import javax.annotation.Nullable; import javax.annotation.Nullable;
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.model; package org.eclipsefoundation.git.eca.model;
import javax.annotation.Nullable; import javax.annotation.Nullable;
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.model; package org.eclipsefoundation.git.eca.model;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -21,7 +23,8 @@ import com.google.auto.value.AutoValue; ...@@ -21,7 +23,8 @@ import com.google.auto.value.AutoValue;
import com.google.auto.value.extension.memoized.Memoized; import com.google.auto.value.extension.memoized.Memoized;
/** /**
* Represents a project in the Eclipse API, along with the users and repos that exist within the context of the project. * Represents a project in the Eclipse API, along with the users and repos that
* exist within the context of the project.
* *
* @author Martin Lowe * @author Martin Lowe
* *
...@@ -45,7 +48,7 @@ public abstract class Project { ...@@ -45,7 +48,7 @@ public abstract class Project {
public abstract List<Repo> getGerritRepos(); public abstract List<Repo> getGerritRepos();
public abstract Object getSpecProjectWorkingGroup(); public abstract Object getSpecProjectWorkingGroup();
public abstract GitlabProject getGitlab(); public abstract GitlabProject getGitlab();
@Nullable @Nullable
...@@ -88,7 +91,7 @@ public abstract class Project { ...@@ -88,7 +91,7 @@ public abstract class Project {
public abstract Builder setGerritRepos(List<Repo> gerritRepos); public abstract Builder setGerritRepos(List<Repo> gerritRepos);
public abstract Builder setSpecProjectWorkingGroup(Object specProjectWorkingGroup); public abstract Builder setSpecProjectWorkingGroup(Object specProjectWorkingGroup);
public abstract Builder setGitlab(GitlabProject gitlab); public abstract Builder setGitlab(GitlabProject gitlab);
public abstract Project build(); public abstract Project build();
......
/** ***************************************************************************** Copyright (C) 2020 /*********************************************************************
* Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* <p>This program and the accompanying materials are made available under the terms of the Eclipse * This program and the accompanying materials are made
* Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/ * available under the terms of the Eclipse Public License 2.0
* * which is available at https://www.eclipse.org/legal/epl-2.0/
* <p>SPDX-License-Identifier: EPL-2.0 *
* *****************************************************************************/ * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.model; package org.eclipsefoundation.git.eca.model;
import java.net.URI; import java.net.URI;
......
/** /*********************************************************************
* Copyright (C) 2020 * Copyright (c) 2020 Eclipse Foundation.
* Eclipse Foundation *
* * This program and the accompanying materials are made
* <p>This program and the accompanying materials are made available under the terms of the Eclipse * available under the terms of the Eclipse Public License 2.0
* Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* <p>SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
* *
*/ * SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.model; package org.eclipsefoundation.git.eca.model;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
...@@ -44,7 +45,7 @@ public abstract class ValidationResponse { ...@@ -44,7 +45,7 @@ public abstract class ValidationResponse {
public abstract boolean getTrackedProject(); public abstract boolean getTrackedProject();
public abstract boolean getStrictMode(); public abstract boolean getStrictMode();
public abstract String getFingerprint(); public abstract String getFingerprint();
public boolean getPassed() { public boolean getPassed() {
...@@ -78,8 +79,8 @@ public abstract class ValidationResponse { ...@@ -78,8 +79,8 @@ public abstract class ValidationResponse {
/** /**
* Converts the APIResponse to a web response with appropriate status. * Converts the APIResponse to a web response with appropriate status.
* *
* @return a web response with status {@link Status.OK} if the commits pass validation, {@link Status.FORBIDDEN} * @return a web response with status {@link Status.OK} if the commits pass
* otherwise. * validation, {@link Status.FORBIDDEN} otherwise.
*/ */
public Response toResponse() { public Response toResponse() {
// update error count before returning // update error count before returning
...@@ -105,7 +106,7 @@ public abstract class ValidationResponse { ...@@ -105,7 +106,7 @@ public abstract class ValidationResponse {
public abstract Builder setTrackedProject(boolean trackedProject); public abstract Builder setTrackedProject(boolean trackedProject);
public abstract Builder setStrictMode(boolean strictMode); public abstract Builder setStrictMode(boolean strictMode);
public abstract Builder setFingerprint(String fingerprint); public abstract Builder setFingerprint(String fingerprint);
public abstract ValidationResponse build(); public abstract ValidationResponse build();
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.namespace; package org.eclipsefoundation.git.eca.namespace;
import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonValue;
public enum APIStatusCode { public enum APIStatusCode {
SUCCESS_DEFAULT(200), SUCCESS_COMMITTER(201), SUCCESS_CONTRIBUTOR(202),SUCCESS_SKIPPED(203), ERROR_DEFAULT(-401), ERROR_SIGN_OFF(-402), SUCCESS_DEFAULT(200),
ERROR_SPEC_PROJECT(-403), ERROR_AUTHOR(-404), ERROR_COMMITTER(-405), ERROR_PROXY_PUSH(-406); SUCCESS_COMMITTER(201),
SUCCESS_CONTRIBUTOR(202),
SUCCESS_SKIPPED(203),
ERROR_DEFAULT(-401),
ERROR_SIGN_OFF(-402),
ERROR_SPEC_PROJECT(-403),
ERROR_AUTHOR(-404),
ERROR_COMMITTER(-405),
ERROR_PROXY_PUSH(-406);
private int code; private int code;
......
/*********************************************************************
* Copyright (c) 2022 Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.namespace; package org.eclipsefoundation.git.eca.namespace;
import java.util.Arrays; import java.util.Arrays;
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.namespace; package org.eclipsefoundation.git.eca.namespace;
import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonValue;
......
/******************************************************************************* /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2020 Eclipse Foundation.
* *
* This program and the accompanying materials are made * This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 * available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/ * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* SPDX-License-Identifier: EPL-2.0 * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
******************************************************************************/ *
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.oauth; package org.eclipsefoundation.git.eca.oauth;
import com.github.scribejava.core.builder.api.DefaultApi20; import com.github.scribejava.core.builder.api.DefaultApi20;
......
/** /*********************************************************************
* Copyright (C) 2020 Eclipse Foundation * Copyright (c) 2022 Eclipse Foundation.
* *
* <p>This program and the accompanying materials are made available under the terms of the Eclipse * This program and the accompanying materials are made
* Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/ * available under the terms of the Eclipse Public License 2.0
* * which is available at https://www.eclipse.org/legal/epl-2.0/
* <p>SPDX-License-Identifier: EPL-2.0 *
*/ * Author: Martin Lowe <martin.lowe@eclipse-foundation.org>
* Zachary Sabourin <zachary.sabourin@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.git.eca.resource; package org.eclipsefoundation.git.eca.resource;
import java.net.MalformedURLException; import java.net.MalformedURLException;
...@@ -52,8 +56,9 @@ import io.quarkus.qute.Location; ...@@ -52,8 +56,9 @@ import io.quarkus.qute.Location;
import io.quarkus.qute.Template; import io.quarkus.qute.Template;
/** /**
* ECA validation endpoint for Git commits. Will use information from the bots, projects, and accounts API to validate * ECA validation endpoint for Git commits. Will use information from the bots,
* commits passed to this endpoint. Should be as system agnostic as possible to allow for any service to request * projects, and accounts API to validate commits passed to this endpoint.
* Should be as system agnostic as possible to allow for any service to request
* validation with less reliance on services external to the Eclipse foundation. * validation with less reliance on services external to the Eclipse foundation.
* *
* @author Martin Lowe, Zachary Sabourin * @author Martin Lowe, Zachary Sabourin
...@@ -89,14 +94,16 @@ public class ValidationResource { ...@@ -89,14 +94,16 @@ public class ValidationResource {
Template membershipTemplateWeb; Template membershipTemplateWeb;
/** /**
* Consuming a JSON request, this method will validate all passed commits, using the repo URL and the repository * Consuming a JSON request, this method will validate all passed commits, using
* provider. These commits will be validated to ensure that all users are covered either by an ECA, or are * the repo URL and the repository provider. These commits will be validated to
* committers on the project. In the case of ECA-only contributors, an additional sign off footer is required in the * ensure that all users are covered either by an ECA, or are committers on the
* body of the commit. * project. In the case of ECA-only contributors, an additional sign off footer
* is required in the body of the commit.
* *
* @param req the request containing basic data plus the commits to be validated * @param req the request containing basic data plus the commits to be validated
* @return a web response indicating success or failure for each commit, along with standard messages that may be * @return a web response indicating success or failure for each commit, along
* used to give users context on failure. * with standard messages that may be
* used to give users context on failure.
* @throws MalformedURLException * @throws MalformedURLException
*/ */
@POST @POST
...@@ -112,8 +119,10 @@ public class ValidationResource { ...@@ -112,8 +119,10 @@ public class ValidationResource {
.setStrictMode(req.getStrictMode() != null && req.getStrictMode() ? true : false) .setStrictMode(req.getStrictMode() != null && req.getStrictMode() ? true : false)
.setTrackedProject(!filteredProjects.isEmpty()).setFingerprint(validation.generateRequestHash(req)) .setTrackedProject(!filteredProjects.isEmpty()).setFingerprint(validation.generateRequestHash(req))
.build(); .build();
List<CommitValidationStatus> statuses = validation.getRequestCommitValidationStatus(wrapper, req, List<CommitValidationStatus> statuses = validation.getRequestCommitValidationStatus(wrapper, req,
filteredProjects.isEmpty() ? null : filteredProjects.get(0).getProjectId()); filteredProjects.isEmpty() ? null : filteredProjects.get(0).getProjectId());
for (Commit c : req.getCommits()) { for (Commit c : req.getCommits()) {
// get the current status if present // get the current status if present
Optional<CommitValidationStatus> status = statuses.stream() Optional<CommitValidationStatus> status = statuses.stream()
...@@ -162,30 +171,31 @@ public class ValidationResource { ...@@ -162,30 +171,31 @@ public class ValidationResource {
return Response.ok().entity(membershipTemplateWeb.data("statuses", statuses, "repoUrl", return Response.ok().entity(membershipTemplateWeb.data("statuses", statuses, "repoUrl",
statuses.get(0).getRepoUrl(), "project", projects.isEmpty() ? null : projects.get(0)).render()).build(); statuses.get(0).getRepoUrl(), "project", projects.isEmpty() ? null : projects.get(0)).render()).build();
} }
@GET @GET
@Path("/lookup") @Path("/lookup")
public Response getUserStatus(@QueryParam("email") String email) { public Response getUserStatus(@QueryParam("email") String email) {
EclipseUser user = users.getUser(email); EclipseUser user = users.getUser(email);
if (Objects.isNull(user)) { if (Objects.isNull(user)) {
return Response.status(404).build(); return Response.status(404).build();
} }
if(!user.getECA().getSigned()) { if (!user.getECA().getSigned()) {
return Response.status(403).build(); return Response.status(403).build();
} }
return Response.ok().build(); return Response.ok().build();
} }
/** /**
* Check if there are any issues with the validation request, returning error messages if there are issues with the * Check if there are any issues with the validation request, returning error
* request. * messages if there are issues with the request.
* *
* @param req the current validation request * @param req the current validation request
* @return a list of error messages to report, or an empty list if there are no errors with the request. * @return a list of error messages to report, or an empty list if there are no
* errors with the request.
*/ */
private List<String> checkRequest(ValidationRequest req) { private List<String> checkRequest(ValidationRequest req) {
// check that we have commits to validate // check that we have commits to validate
...@@ -205,11 +215,12 @@ public class ValidationResource { ...@@ -205,11 +215,12 @@ public class ValidationResource {
} }
/** /**
* Process the current request, validating that the passed commit is valid. The author and committers Eclipse * Process the current request, validating that the passed commit is valid. The
* Account is retrieved, which are then used to check if the current commit is valid for the current project. * author and committers Eclipse Account is retrieved, which are then used to
* check if the current commit is valid for the current project.
* *
* @param c the commit to process * @param c the commit to process
* @param response the response container * @param response the response container
* @param filteredProjects tracked projects for the current request * @param filteredProjects tracked projects for the current request
* @return true if we should continue processing, false otherwise. * @return true if we should continue processing, false otherwise.
*/ */
...@@ -279,14 +290,16 @@ public class ValidationResource { ...@@ -279,14 +290,16 @@ public class ValidationResource {
} }
/** /**
* Validates author access for the current commit. If there are errors, they are recorded in the response for the * Validates author access for the current commit. If there are errors, they are
* current request to be returned once all validation checks are completed. * recorded in the response for the current request to be returned once all
* validation checks are completed.
* *
* @param r the current response object for the request * @param r the current response object for the request
* @param c the commit that is being validated * @param c the commit that is being validated
* @param eclipseUser the user to validate on a branch * @param eclipseUser the user to validate on a branch
* @param filteredProjects tracked projects for the current request * @param filteredProjects tracked projects for the current request
* @param errorCode the error code to display if the user does not have access * @param errorCode the error code to display if the user does not have
* access
*/ */
private void validateUserAccess(ValidationResponse r, Commit c, EclipseUser eclipseUser, private void validateUserAccess(ValidationResponse r, Commit c, EclipseUser eclipseUser,
List<Project> filteredProjects, APIStatusCode errorCode) { List<Project> filteredProjects, APIStatusCode errorCode) {
...@@ -296,14 +309,15 @@ public class ValidationResource { ...@@ -296,14 +309,15 @@ public class ValidationResource {
} }
/** /**
* Allows for isCommitter to be called external to this method. This was extracted to ensure that isCommitter isn't * Allows for isCommitter to be called external to this method. This was
* called twice for the same user when checking committer proxy push rules and committer general access. * extracted to ensure that isCommitter isn't called twice for the same user
* when checking committer proxy push rules and committer general access.
* *
* @param r the current response object for the request * @param r the current response object for the request
* @param c the commit that is being validated * @param c the commit that is being validated
* @param eclipseUser the user to validate on a branch * @param eclipseUser the user to validate on a branch
* @param isCommitter the results of the isCommitter call from this class. * @param isCommitter the results of the isCommitter call from this class.
* @param errorCode the error code to display if the user does not have access * @param errorCode the error code to display if the user does not have access
*/ */
private void validateUserAccessPartial(ValidationResponse r, Commit c, EclipseUser eclipseUser, boolean isCommitter, private void validateUserAccessPartial(ValidationResponse r, Commit c, EclipseUser eclipseUser, boolean isCommitter,
APIStatusCode errorCode) { APIStatusCode errorCode) {
...@@ -336,16 +350,19 @@ public class ValidationResource { ...@@ -336,16 +350,19 @@ public class ValidationResource {
} }
/** /**
* Checks whether the given user is a committer on the project. If they are and the project is also a specification * Checks whether the given user is a committer on the project. If they are and
* for a working group, an additional access check is made against the user. * the project is also a specification for a working group, an additional access
* check is made against the user.
* *
* <p> * <p>
* Additionally, a check is made to see if the user is a registered bot user for the given project. If they match * Additionally, a check is made to see if the user is a registered bot user for
* for the given project, they are granted committer-like access to the repository. * the given project. If they match
* for the given project, they are granted committer-like access to the
* repository.
* *
* @param r the current response object for the request * @param r the current response object for the request
* @param user the user to validate on a branch * @param user the user to validate on a branch
* @param hash the hash of the commit that is being validated * @param hash the hash of the commit that is being validated
* @param filteredProjects tracked projects for the current request * @param filteredProjects tracked projects for the current request
* @return true if user is considered a committer, false otherwise. * @return true if user is considered a committer, false otherwise.
*/ */
...@@ -384,11 +401,12 @@ public class ValidationResource { ...@@ -384,11 +401,12 @@ public class ValidationResource {
} }
/** /**
* Retrieves projects valid for the current request, or an empty list if no data or matching project repos could be * Retrieves projects valid for the current request, or an empty list if no data
* found. * or matching project repos could be found.
* *
* @param req the current request * @param req the current request
* @return list of matching projects for the current request, or an empty list if none found. * @return list of matching projects for the current request, or an empty list
* if none found.
*/ */
private List<Project> retrieveProjectsForRequest(ValidationRequest req) { private List<Project> retrieveProjectsForRequest(ValidationRequest req) {
String repoUrl = req.getRepoUrl().getPath(); String repoUrl = req.getRepoUrl().getPath();
...@@ -400,9 +418,10 @@ public class ValidationResource { ...@@ -400,9 +418,10 @@ public class ValidationResource {
} }
/** /**
* Retrieves projects for given provider, using the repo URL to match to a stored repository. * Retrieves projects for given provider, using the repo URL to match to a
* stored repository.
* *
* @param repoUrl the repo URL to match * @param repoUrl the repo URL to match
* @param provider the provider that is being served for the request. * @param provider the provider that is being served for the request.
* @return a list of matching projects, or an empty list if none are found. * @return a list of matching projects, or an empty list if none are found.
*/ */
...@@ -446,12 +465,14 @@ public class ValidationResource { ...@@ -446,12 +465,14 @@ public class ValidationResource {
} }
/** /**
* Retrieves an Eclipse Account user object given the Git users email address (at minimum). This is facilitated * Retrieves an Eclipse Account user object given the Git users email address
* using the Eclipse Foundation accounts API, along short lived in-memory caching for performance and some * (at minimum). This is facilitated using the Eclipse Foundation accounts API,
* protection against duplicate requests. * along short lived in-memory caching for performance and some protection
* against duplicate requests.
* *
* @param user the user to retrieve Eclipse Account information for * @param user the user to retrieve Eclipse Account information for
* @return the Eclipse Account user information if found, or null if there was an error or no user exists. * @return the Eclipse Account user information if found, or null if there was
* an error or no user exists.
*/ */
private EclipseUser getIdentifiedUser(GitUser user) { private EclipseUser getIdentifiedUser(GitUser user) {
// get the Eclipse account for the user // get the Eclipse account for the user
......
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