ERROR: com.atlassian.jira.user.ApplicationUser cannot be converted to com.atlassian.crowd.embedded.api.User

Hi,
When I compile my code, I take this error message:
com.atlassian.jira.user.ApplicationUser cannot be converted to com.atlassian.crowd.embedded.api.User
for this line:

ReportResultModel rrm = new ReportResultModel(changeHistory.getIssue(), cib.getFromString(), cib.getToString(), changeHistory.getAuthorObject(), assigneeUser, groupName, changeHistory.getIssue().getReporterUser(), diffDays, simpleHours, 1);

How can I fix this error for Jira 8 version ? Is there any changing usage of ChangeHistoryManager or something else?
Thank you

You can transform an ApplicationUser to a DirectoryUser via ApplicationUsers.toDirectoryUser() (see ApplicationUsers (Atlassian Jira - Server 8.16.2 API))

So that would change your code to:

ApplicationUser user = changeHistory.getAuthorObject();
User directoryUser = ApplicationUsers.toDirectoryUser(user);

ReportResultModel rrm = new ReportResultModel(changeHistory.getIssue(), cib.getFromString(), cib.getToString(), directoryUser, assigneeUser, groupName, changeHistory.getIssue().getReporterUser(), diffDays, simpleHours, 1);
1 Like

Where is the User class come from ?

It does help to actually click on the documentation link I added in my response… but let me copy that verbatim for you:

toDirectoryUser
@Nullable
public static com.atlassian.crowd.embedded.api.User toDirectoryUser(@Nullable
                                                                              ApplicationUser user)
Does a null-safe conversion from an application user to a directory user.
Parameters:
user - the ApplicationUser
Returns:
the corresponding Directory user

Isn’t the use of EmbeddedApi removed with Jira 8?

The link is referring to the 8.16.2 documentation, so guess not?