Привел в порядок имена переменных для urls

This commit is contained in:
Struchkov Mark 2022-12-20 21:14:19 +03:00
parent a5e706a524
commit b8c3fc6b25
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6
8 changed files with 64 additions and 60 deletions

View File

@ -18,50 +18,54 @@ public class GitlabProperty {
private String baseUrl; private String baseUrl;
/** private String replaceUrl;
* Адрес, по которому можно получить открытые ПР
*/
private String urlMergeRequestOpen;
/**
* Адрес, по которому можно получить закрытые ПР
*/
private String urlMergeRequestClose;
/**
* Адрес, по которому можно получить комментарии к ПР
*/
private String urlMergeRequestComment;
/**
* Адрес ПР
*/
private String urlMergeRequest;
private String urlProject;
private String userUrl;
private String usersUrl; private String usersUrl;
private String urlMergeRequestAdd; private String userUrl;
private String urlNote; private String projectsUrl;
private String urlNoteApi; /**
* Адрес, по которому можно получить открытые MR
*/
private String openMergeRequestsUrl;
private String urlPipelines; /**
* Адрес, по которому можно получить закрытые MR
*/
private String closeMergeRequestsUrl;
private String urlPipeline; /**
* Адрес, по которому можно получить комментарии к MR
*/
private String commentsOfMergeRequestUrl;
private String urlCommit; /**
* Адрес MR
*/
private String mergeRequestUrl;
private String urlNewNote; private String projectAddUrl;
private String urlDiscussion; private String noteUrl;
private String urlOneDiscussion; private String notesOfMergeRequestUrl;
private String pipelinesUrl;
private String pipelineUrl;
private String lastCommitOfMergeRequestUrl;
private String newNoteUrl;
/**
* Адрес дискуссий для MR
*/
private String discussionsUrl;
private String discussionUrl;
private String replaceUrl;
} }

View File

@ -250,7 +250,7 @@ public class DiscussionServiceImpl implements DiscussionService {
final MergeRequest mergeRequest = discussion.getMergeRequest(); final MergeRequest mergeRequest = discussion.getMergeRequest();
final Long projectId = mergeRequest.getProjectId(); final Long projectId = mergeRequest.getProjectId();
final String requestUrl = MessageFormat.format(gitlabProperty.getUrlNewNote(), projectId, mergeRequest.getTwoId(), discussion.getId(), text); final String requestUrl = MessageFormat.format(gitlabProperty.getNewNoteUrl(), projectId, mergeRequest.getTwoId(), discussion.getId(), text);
RequestBody formBody = new FormBody.Builder().build(); RequestBody formBody = new FormBody.Builder().build();

View File

@ -184,7 +184,7 @@ public class DiscussionParser {
private String createLinkOldDiscussion(Discussion discussion) { private String createLinkOldDiscussion(Discussion discussion) {
return MessageFormat.format( return MessageFormat.format(
gitlabProperty.getUrlOneDiscussion(), gitlabProperty.getDiscussionUrl(),
discussion.getMergeRequest().getProjectId(), discussion.getMergeRequest().getProjectId(),
discussion.getMergeRequest().getTwoId(), discussion.getMergeRequest().getTwoId(),
discussion.getId() discussion.getId()
@ -192,7 +192,7 @@ public class DiscussionParser {
} }
private List<DiscussionJson> getDiscussionJson(MergeRequest mergeRequest, int page) { private List<DiscussionJson> getDiscussionJson(MergeRequest mergeRequest, int page) {
return HttpParse.request(MessageFormat.format(gitlabProperty.getUrlDiscussion(), mergeRequest.getProjectId(), mergeRequest.getTwoId(), page)) return HttpParse.request(MessageFormat.format(gitlabProperty.getDiscussionsUrl(), mergeRequest.getProjectId(), mergeRequest.getTwoId(), page))
.header(ACCEPT) .header(ACCEPT)
.header(H_PRIVATE_TOKEN, personProperty.getToken()) .header(H_PRIVATE_TOKEN, personProperty.getToken())
.executeList(DiscussionJson.class); .executeList(DiscussionJson.class);
@ -201,7 +201,7 @@ public class DiscussionParser {
private Consumer<Note> createNoteLink(MergeRequest mergeRequest) { private Consumer<Note> createNoteLink(MergeRequest mergeRequest) {
return note -> { return note -> {
final String url = MessageFormat.format( final String url = MessageFormat.format(
gitlabProperty.getUrlNote(), gitlabProperty.getNoteUrl(),
mergeRequest.getWebUrl(), mergeRequest.getWebUrl(),
note.getId() note.getId()
); );

View File

@ -92,7 +92,7 @@ public class MergeRequestParser {
final List<ForkJoinTask<Optional<MergeRequestJson>>> tasks = existIds.stream() final List<ForkJoinTask<Optional<MergeRequestJson>>> tasks = existIds.stream()
.map( .map(
existId -> new GetSingleMergeRequestTask( existId -> new GetSingleMergeRequestTask(
gitlabProperty.getUrlMergeRequest(), gitlabProperty.getMergeRequestUrl(),
existId.getProjectId(), existId.getProjectId(),
existId.getTwoId(), existId.getTwoId(),
personProperty.getToken() personProperty.getToken()
@ -146,7 +146,7 @@ public class MergeRequestParser {
*/ */
private List<MergeRequestJson> getMergeRequests(Set<Long> projectIds) { private List<MergeRequestJson> getMergeRequests(Set<Long> projectIds) {
final List<ForkJoinTask<List<MergeRequestJson>>> tasks = projectIds.stream() final List<ForkJoinTask<List<MergeRequestJson>>> tasks = projectIds.stream()
.map(projectId -> new GetAllMergeRequestForProjectTask(projectId, gitlabProperty.getUrlMergeRequestOpen(), personProperty.getToken())) .map(projectId -> new GetAllMergeRequestForProjectTask(projectId, gitlabProperty.getOpenMergeRequestsUrl(), personProperty.getToken()))
.map(forkJoinPool::submit) .map(forkJoinPool::submit)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -181,7 +181,7 @@ public class MergeRequestParser {
private void parsingCommits(MergeRequest mergeRequest) { private void parsingCommits(MergeRequest mergeRequest) {
final List<CommitJson> commitJson = HttpParse.request( final List<CommitJson> commitJson = HttpParse.request(
MessageFormat.format(gitlabProperty.getUrlCommit(), mergeRequest.getProjectId(), mergeRequest.getTwoId()) MessageFormat.format(gitlabProperty.getLastCommitOfMergeRequestUrl(), mergeRequest.getProjectId(), mergeRequest.getTwoId())
) )
.header(ACCEPT) .header(ACCEPT)
.header(StringUtils.H_PRIVATE_TOKEN, personProperty.getToken()) .header(StringUtils.H_PRIVATE_TOKEN, personProperty.getToken())

View File

@ -102,7 +102,7 @@ public class PipelineParser {
private List<Pipeline> getNewPipelines(Map<Long, Long> pipelineProjectMap, Set<Long> idsNotFound) { private List<Pipeline> getNewPipelines(Map<Long, Long> pipelineProjectMap, Set<Long> idsNotFound) {
final List<ForkJoinTask<Optional<PipelineJson>>> tasks = idsNotFound.stream() final List<ForkJoinTask<Optional<PipelineJson>>> tasks = idsNotFound.stream()
.map(pipelineId -> new GetPipelineTask( .map(pipelineId -> new GetPipelineTask(
gitlabProperty.getUrlPipeline(), gitlabProperty.getPipelineUrl(),
pipelineProjectMap.get(pipelineId), pipelineProjectMap.get(pipelineId),
pipelineId, pipelineId,
personProperty.getToken() personProperty.getToken()
@ -120,7 +120,7 @@ public class PipelineParser {
LocalDateTime newLastUpdate = LocalDateTime.now(); LocalDateTime newLastUpdate = LocalDateTime.now();
final List<ForkJoinTask<List<PipelineShortJson>>> tasks = projectIds.stream() final List<ForkJoinTask<List<PipelineShortJson>>> tasks = projectIds.stream()
.map(projectId -> new GetPipelineShortTask( .map(projectId -> new GetPipelineShortTask(
gitlabProperty.getUrlPipelines(), gitlabProperty.getPipelinesUrl(),
projectId, projectId,
lastUpdate, lastUpdate,
personProperty.getToken() personProperty.getToken()
@ -142,7 +142,7 @@ public class PipelineParser {
final List<ForkJoinTask<Optional<PipelineJson>>> tasks = pipelines.stream() final List<ForkJoinTask<Optional<PipelineJson>>> tasks = pipelines.stream()
.map( .map(
pipeline -> new GetPipelineTask( pipeline -> new GetPipelineTask(
gitlabProperty.getUrlPipeline(), gitlabProperty.getPipelineUrl(),
pipeline.getProjectId(), pipeline.getProjectId(),
pipeline.getId(), pipeline.getId(),
personProperty.getToken() personProperty.getToken()

View File

@ -120,7 +120,7 @@ public class ProjectParser {
private List<ProjectJson> getProjectJsons(int page, String... params) { private List<ProjectJson> getProjectJsons(int page, String... params) {
String param = String.join("", params); String param = String.join("", params);
final String url = MessageFormat.format(gitlabProperty.getUrlProject(), page); final String url = MessageFormat.format(gitlabProperty.getProjectsUrl(), page);
return HttpParse.request(url + param) return HttpParse.request(url + param)
.header(ACCEPT) .header(ACCEPT)
.header(StringUtils.H_PRIVATE_TOKEN, personProperty.getToken()) .header(StringUtils.H_PRIVATE_TOKEN, personProperty.getToken())

View File

@ -35,19 +35,19 @@ gitlab-bot:
gitlab: gitlab:
base-url: ${GITLAB_URL} base-url: ${GITLAB_URL}
replaceUrl: ${GITLAB_REPLACE_URL} replaceUrl: ${GITLAB_REPLACE_URL}
url-project: ${GITLAB_URL}/api/v4/projects?page={0, number, integer}&per_page=100
url-merge-request-open: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests?state=opened&page={1, number, integer}&per_page={2, number, integer}"
url-merge-request-close: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests?state=closed&page={1, number, integer}&per_page=100"
url-merge-request-comment: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/notes?&page={2,number,#}&per_page=100"
url-merge-request: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}"
url-merge-request-add: "${GITLAB_URL}/api/v4/projects/"
user-url: ${GITLAB_URL}/api/v4/user
users-url: ${GITLAB_URL}/api/v4/users users-url: ${GITLAB_URL}/api/v4/users
url-note: "{0}#note_{1,number,#}" user-url: ${GITLAB_URL}/api/v4/user
url-note-api: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/notes/{2,number,#}" projects-url: "${GITLAB_URL}/api/v4/projects?page={0, number, integer}&per_page=100"
url-pipelines: "${GITLAB_URL}/api/v4/projects/{0,number,#}/pipelines?&page={1,number,#}&per_page={2,number,#}" open-merge-requests-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests?state=opened&page={1, number, integer}&per_page={2, number, integer}"
url-pipeline: "${GITLAB_URL}/api/v4/projects/{0,number,#}/pipelines/{1,number,#}" close-merge-requests-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests?state=closed&page={1, number, integer}&per_page=100"
url-commit: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/commits?&page=1&per_page=1" comments-of-merge-request-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/notes?&page={2,number,#}&per_page=100"
url-new-note: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions/{2}/notes?body={3}" merge-request-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}"
url-discussion: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions?&page={2,number,#}&per_page=100" project-add-url: "${GITLAB_URL}/api/v4/projects/"
url-one-discussion: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions/{2}" note-url: "{0}#note_{1,number,#}"
notes-of-merge-request-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/notes/{2,number,#}"
pipelines-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/pipelines?&page={1,number,#}&per_page={2,number,#}"
pipeline-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/pipelines/{1,number,#}"
last-commit-of-merge-request-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/commits?&page=1&per_page=1"
new-note-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions/{2}/notes?body={3}"
discussions-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions?&page={2,number,#}&per_page=100"
discussion-url: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions/{2}"

View File

@ -91,7 +91,7 @@ public class MenuConfig {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.answer(mail -> { .answer(mail -> {
final String mailText = mail.getText(); final String mailText = mail.getText();
final String projectUrl = gitlabProperty.getUrlMergeRequestAdd() + mailText.replace(gitlabProperty.getBaseUrl(), "") final String projectUrl = gitlabProperty.getProjectAddUrl() + mailText.replace(gitlabProperty.getBaseUrl(), "")
.substring(1) .substring(1)
.replace("/", "%2F"); .replace("/", "%2F");
projectParser.parseByUrl(projectUrl); projectParser.parseByUrl(projectUrl);