Reporter not set from IssueInputParameters

XMLWordPrintable

    • 4.01

      I am trying to develop a plugin that allows creation of tickets via a rest service. The problem I am having, is that to get it to work, I have to set the permissions to allow anybody to create an issue, also the Reporter is not being set, even though I have it specified in the IssueInputParameters. Am i going about this the wrong way, or is this a bug? Find code below:

      @Path ( "/ticket" )
      public class TicketResource {

      @GET
      @AnonymousAllowed
      @Consumes (

      {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}

      )
      @Produces (

      {MediaType.TEXT_HTML, MediaType.TEXT_PLAIN}

      )
      public String createTicket(@QueryParam ( "id" ) String id,
      @QueryParam ( "summary" ) String summary,
      @QueryParam ( "description" ) String description ) {
      if ( id == null || summary == null || description == null )
      return "Fail - params not set";
      else {
      User user = null;
      try

      { user = UserManager.getInstance().getUser("admin"); }

      catch ( EntityNotFoundException e )

      { e.printStackTrace(); }

      IssueInputParameters issueInputParameters = new IssueInputParametersImpl();
      issueInputParameters.setProjectId(ManagerFactory.getProjectManager().getProjectObjByKey("TECH").getId())
      .setIssueTypeId("2")
      .setSummary(summary)
      .setReporterId("admin")
      .setAssigneeId("admin")
      .setDescription(description)
      .setEnvironment("I am an environment")
      .setStatusId("2")
      .setPriorityId("2");
      IssueService issueService = ComponentManager.getInstance().getIssueService();

      IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(user,
      issueInputParameters);

      if ( createValidationResult.isValid() ) {
      IssueService.IssueResult createResult = issueService.create(user, createValidationResult);
      if ( !createResult.isValid() )

      { return "Fail"; }

      } else

      { return createValidationResult.getErrorCollection().getErrorMessages().toArray()[0].toString(); }

      return "Pass";

      }
      }

      }

            Assignee:
            Unassigned
            Reporter:
            Matthew Potter
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: