Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to production #74

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkus.rest.client.reactive.ClientExceptionMapper;
import io.quarkus.rest.client.reactive.ClientQueryParam;
import io.quarkus.rest.client.reactive.jackson.ClientObjectMapper;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
Expand All @@ -41,8 +40,10 @@
* version (included), e.g.:
*/
// so that we do not spam with all notifications ...
// since `notifyUsers=false` does not apply to all requests and we've disabled notifications downstream
// this query param is not sent anymore to allow automation updating upstream issues to work with a non-admin user.
// since `notifyUsers=false` does not apply to all requests and we've disabled
// notifications downstream
// this query param is not sent anymore to allow automation updating upstream
// issues to work with a non-admin user.
// @ClientQueryParam(name = "notifyUsers", value = "false")
public interface JiraRestClient {

Expand Down Expand Up @@ -150,7 +151,7 @@ JiraIssues find(@QueryParam("jql") String query, @QueryParam("startAt") int star

@GET
@Path("/issue/{issueKey}/transitions")
JiraTransitions availableTransitions(String issueKey);
JiraTransitions availableTransitions(@PathParam("issueKey") String issueKey);

@PUT
@Path("/issue/{issueKey}/archive")
Expand All @@ -172,6 +173,10 @@ JiraIssues find(@QueryParam("jql") String query, @QueryParam("startAt") int star
@Path("/version/{id}")
JiraVersion update(@PathParam("id") String id, JiraVersion version);

@PUT
@Path("/issue/{issueKey}/assignee")
void assign(@PathParam("issueKey") String id, JiraUser assignee);

@ClientObjectMapper
static ObjectMapper objectMapper(ObjectMapper defaultObjectMapper) {
return defaultObjectMapper.copy().setDefaultPropertyInclusion(JsonInclude.Include.NON_EMPTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ public JiraVersion update(String id, JiraVersion version) {
return withRetry(() -> delegate.update(id, version));
}

@Override
public void assign(String id, JiraUser assignee) {
withRetry(() -> delegate.assign(id, assignee));
}

private static final int RETRIES = 5;
private static final Duration WAIT_BETWEEN_RETRIES = Duration.of(2, ChronoUnit.SECONDS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.hibernate.infra.replicate.jira.service.jira.HandlerProjectContext;
import org.hibernate.infra.replicate.jira.service.jira.model.action.JiraActionEvent;
import org.hibernate.infra.replicate.jira.service.jira.model.rest.JiraFields;
import org.hibernate.infra.replicate.jira.service.jira.model.rest.JiraIssue;
import org.hibernate.infra.replicate.jira.service.jira.model.rest.JiraUser;
import org.hibernate.infra.replicate.jira.service.reporting.ReportingConfig;
Expand All @@ -18,20 +17,20 @@ public JiraAssigneeActionEventHandler(ReportingConfig reportingConfig, HandlerPr
protected void doRun() {
JiraIssue issue = context.destinationJiraClient().getIssue(event.key);

JiraIssue updated = new JiraIssue();
updated.fields = JiraFields.empty();
JiraUser user = null;
if (issue.fields.assignee != null) {
String accountId = context.upstreamUser(
issue.fields.assignee.mappedIdentifier(context.projectGroup().users().mappedPropertyName()));

if (accountId != null) {
updated.fields.assignee = new JiraUser(accountId);

user = new JiraUser(accountId);
}
} else {
updated.fields.assignee = new JiraUser("-1");
user = new JiraUser("-1");
}
if (user != null) {
context.sourceJiraClient().assign(toSourceKey(event.key), user);
}
context.sourceJiraClient().update(toSourceKey(event.key), updated);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ public JiraVersion update(String id, JiraVersion version) {
return version;
}

@Override
public void assign(String id, JiraUser assignee) {
// ok
}

private JiraIssueLink sampleIssueLink(Long id) {
try {
return objectMapper.readValue("""
Expand Down
Loading