-
Type:
Bug
-
Resolution: Obsolete
-
Priority:
Medium
-
Affects Version/s: 4.1.1
-
Component/s: UPM (Universal Plugin Manager)
-
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 (
)
@Produces (
)
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
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() )
} else
{ return createValidationResult.getErrorCollection().getErrorMessages().toArray()[0].toString(); }return "Pass";
}
}
}