Details
-
Bug
-
Resolution: Fixed
-
Medium
-
3.10
-
3.1
-
Description
While tested code for this issue
http://jira.atlassian.com/browse/JRA-13057
I found that if I pass in a DocumentIssueImpl to the worklog service, it readily takes it and updates the backend issue however the side effect is that the indexes get wrecked. The Issue is light weight and does not have the information that the index needs is missing.
The Worklog service should either "convert the light weight issue" into a real one. OR throw a runtime / validation exception because its not a real MutableIssue.
User user = context.getUser(); try { searchResults = searchProvider.search(request, user, pagerFilter); List issues = searchResults.getIssues(); for (Iterator it = issues.iterator(); it.hasNext();) { Issue issue = (Issue) it.next(); JiraServiceContext jiraServiceContext = new JiraServiceContextImpl(user); WorklogService worklogService = (WorklogService) ComponentManager.getComponentInstanceOfType(WorklogService.class); worklogService.hasPermissionToCreate(jiraServiceContext, issue); Worklog worklog = worklogService.validateCreate(jiraServiceContext, issue, "1h", new Date(), "Comment", null, null); worklogService.createAndRetainRemainingEstimate(jiraServiceContext, worklog, true); } } catch (Throwable e) { e.printStackTrace(); throw new RuntimeException(e); }