diff --git a/server-plugin/server-plugin-import-jiracloud/src/main/java/io/onedev/server/plugin/imports/jiracloud/ImportOption.java b/server-plugin/server-plugin-import-jiracloud/src/main/java/io/onedev/server/plugin/imports/jiracloud/ImportOption.java index 9d72336fb6..74ed36d8c1 100644 --- a/server-plugin/server-plugin-import-jiracloud/src/main/java/io/onedev/server/plugin/imports/jiracloud/ImportOption.java +++ b/server-plugin/server-plugin-import-jiracloud/src/main/java/io/onedev/server/plugin/imports/jiracloud/ImportOption.java @@ -19,7 +19,7 @@ public class ImportOption implements Serializable { private static final long serialVersionUID = 1L; - private String assigneeIssueField; + private String assigneesIssueField; private String dueDateIssueField; @@ -37,16 +37,16 @@ private static GlobalIssueSetting getIssueSetting() { return OneDev.getInstance(SettingManager.class).getIssueSetting(); } - @Editable(order=350, description="Specify a user field to hold assignee information.
" + @Editable(order=350, description="Specify a multi-value user field to hold assignees information.
" + "NOTE: You may customize OneDev issue fields in case there is no appropriate option here") @ChoiceProvider("getAssigneesIssueFieldChoices") @NotEmpty - public String getAssigneeIssueField() { - return assigneeIssueField; + public String getAssigneesIssueField() { + return assigneesIssueField; } - public void setAssigneeIssueField(String assigneeIssueField) { - this.assigneeIssueField = assigneeIssueField; + public void setAssigneesIssueField(String assigneesIssueField) { + this.assigneesIssueField = assigneesIssueField; } @SuppressWarnings("unused") diff --git a/server-plugin/server-plugin-import-jiracloud/src/main/java/io/onedev/server/plugin/imports/jiracloud/ImportServer.java b/server-plugin/server-plugin-import-jiracloud/src/main/java/io/onedev/server/plugin/imports/jiracloud/ImportServer.java index 417041d3b0..16be64e4e3 100644 --- a/server-plugin/server-plugin-import-jiracloud/src/main/java/io/onedev/server/plugin/imports/jiracloud/ImportServer.java +++ b/server-plugin/server-plugin-import-jiracloud/src/main/java/io/onedev/server/plugin/imports/jiracloud/ImportServer.java @@ -157,13 +157,20 @@ private Long getUserId(Map> userIds, JsonNode userNode, T String accountId = userNode.get("accountId").asText(); Optional userIdOpt = userIds.get(accountId); if (userIdOpt == null) { - String displayName = null; - if (userNode.hasNonNull("displayName")) - displayName = userNode.get("displayName").asText(null); - if (displayName != null) - userIdOpt = Optional.ofNullable(User.idOf(OneDev.getInstance(UserManager.class).findByFullName(displayName))); - else - userIdOpt = Optional.empty(); + String emailAddress = null; + if (userNode.hasNonNull("emailAddress")) + emailAddress = userNode.get("emailAddress").asText(null); + if (emailAddress != null) { + userIdOpt = Optional.ofNullable(User.idOf(OneDev.getInstance(UserManager.class).findByVerifiedEmailAddress(emailAddress))); + } else { + String displayName = null; + if (userNode.hasNonNull("displayName")) + displayName = userNode.get("displayName").asText(null); + if (displayName != null) + userIdOpt = Optional.ofNullable(User.idOf(OneDev.getInstance(UserManager.class).findByFullName(displayName))); + else + userIdOpt = Optional.empty(); + } userIds.put(accountId, userIdOpt); } return userIdOpt.orElse(null); @@ -608,7 +615,7 @@ public void consume(List pageData) throws InterruptedException { JsonNode assigneeNode = fieldsNode.get("assignee"); IssueField assigneeField = new IssueField(); assigneeField.setIssue(issue); - assigneeField.setName(option.getAssigneeIssueField()); + assigneeField.setName(option.getAssigneesIssueField()); assigneeField.setType(InputSpec.USER); Long userId = getUserId(userIds, assigneeNode, logger);