Worklog Service should not allow lightweight issues to be passed in and persistened. It wrecks the index view of the world

XMLWordPrintable

    • 3.1

      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);
              }
      

              Assignee:
              Unassigned
              Reporter:
              ɹǝʞɐq pɐɹq
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 2h
                  2h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified