@CheckForNull
public ProjectBadgeTokenDto selectTokenByProject(DbSession session, ProjectDto projectDto) {
return mapper(session).selectTokenByProjectUuid(projectDto.getUuid());
+
}
}
private static final String PARAM_PROJECT = "project";
private static final String PARAM_BRANCH = "branch";
private static final String PARAM_TOKEN = "token";
+ public static final String PROJECT_HAS_NOT_BEEN_FOUND = "Project has not been found";
private final ComponentFinder componentFinder;
private final DbClient dbClient;
return branch;
} catch (NotFoundException e) {
- throw new NotFoundException("Project has not been found");
+ throw new NotFoundException(PROJECT_HAS_NOT_BEEN_FOUND);
}
}
try {
projectDto = componentFinder.getProjectOrApplicationByKey(dbSession, projectKey);
} catch (NotFoundException e) {
- throw new NotFoundException("Project has not been found");
+ throw new NotFoundException(PROJECT_HAS_NOT_BEEN_FOUND);
}
String token = request.param(PARAM_TOKEN);
if (projectDto.isPrivate() && !isTokenValid(dbSession, projectDto, token)) {
- throw generateInvalidProjectException();
+ throw new NotFoundException(PROJECT_HAS_NOT_BEEN_FOUND);
}
}
}
.setParam("metric", metric.getKey())
.execute();
- checkError(response, "Project is invalid");
+ checkError(response, "Project has not been found");
}
@Test
.setParam("project", project.getKey())
.execute();
- checkError(response, "Project is invalid");
+ checkError(response, "Project has not been found");
}
@Test
private String branch;
private String metric;
private String project;
+ private String token;
/**
* Example value: "feature/my_branch"
public String getProject() {
return project;
}
+
+ /**
+ * Tthis an optional parameter.
+ */
+ public MeasureRequest setToken(String token) {
+ this.token = token;
+ return this;
+ }
+
+ public String getToken() {
+ return token;
+ }
}
import javax.annotation.Generated;
import org.sonarqube.ws.MediaTypes;
+import org.sonarqube.ws.ProjectBadgeToken.TokenWsResponse;
import org.sonarqube.ws.client.BaseService;
import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsConnector;
+import org.sonarqube.ws.client.WsResponse;
/**
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/project_badges">Further information about this web service online</a>
.setParam("branch", request.getBranch())
.setParam("metric", request.getMetric())
.setParam("project", request.getProject())
+ .setParam("token", request.getToken())
.setMediaType(MediaTypes.JSON)
).content();
}
new GetRequest(path("quality_gate"))
.setParam("branch", request.getBranch())
.setParam("project", request.getProject())
+ .setParam("token", request.getToken())
.setMediaType(MediaTypes.JSON)
).content();
}
+
+ /**
+ *
+ * This is part of the internal API.
+ * This is a GET request.
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/project_badges/token">Further information about this action online (including a response example)</a>
+ * @since 9.2
+ * @return
+ */
+ public TokenWsResponse token(TokenRequest request) {
+ return call(
+ new GetRequest(path("token"))
+ .setParam("project", request.getProject())
+ .setMediaType(MediaTypes.JSON),
+ TokenWsResponse.parser()
+ );
+ }
+
+
+ public WsResponse renewToken(RenewTokenRequest request) {
+ return call(
+ new PostRequest(path("renew_token"))
+ .setParam("project", request.getProject())
+ .setMediaType(MediaTypes.JSON)
+ );
+
+ }
}
private String branch;
private String project;
+ private String token;
/**
* Example value: "feature/my_branch"
public String getProject() {
return project;
}
+
+ /**
+ * This is aan optional parameter.
+ */
+ public QualityGateRequest setToken(String token) {
+ this.token = token;
+ return this;
+ }
+
+ public String getToken() {
+ return token;
+ }
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonarqube.ws.client.projectbadges;
+
+import javax.annotation.Generated;
+
+/**
+ * This is part of the internal API.
+ * This is a POST request.
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/project_badges/renew_token">Further information about this action online (including a response example)</a>
+ * @since 9.2
+ */
+@Generated("sonar-ws-generator")
+public class RenewTokenRequest {
+
+ private String project;
+
+ /**
+ * This is a mandatory parameter.
+ * Example value: "my_project"
+ */
+ public RenewTokenRequest setProject(String project) {
+ this.project = project;
+ return this;
+ }
+
+ public String getProject() {
+ return project;
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonarqube.ws.client.projectbadges;
+
+import javax.annotation.Generated;
+
+/**
+ * This is part of the internal API.
+ * This is a GET request.
+ * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/project_badges/token">Further information about this action online (including a response example)</a>
+ * @since 9.2
+ */
+@Generated("sonar-ws-generator")
+public class TokenRequest {
+
+ private String project;
+
+ /**
+ * This is a mandatory parameter.
+ * Example value: "my_project"
+ */
+ public TokenRequest setProject(String project) {
+ this.project = project;
+ return this;
+ }
+
+ public String getProject() {
+ return project;
+ }
+}