Using webwork1 with CreateIssueDetails Edited

Hello. I want to add some functions on issue creating.

I have this webwork in my atlassian-plugin.xml:

<webwork1 key="unitera-create-issue-details" name="Unitera Create Issue Details"
class="com.atlassian.jira.web.action.issue.CreateIssueDetails">
<actions>
<action name="org.smedyou.tutorial.ComDescCreateIssueDetails"
alias="CreateIssueDetails"
roles-required="use">
<view name="error">/secure/views/createissue-details.jsp</view>
</action>
</actions>
</webwork1>

And this class, which extends CreateIssueDetails.class, as seen

 

package org.smedyou.tutorial;

import com.atlassian.gzipfilter.org.apache.commons.lang.exception.ExceptionUtils;
import com.atlassian.jira.bc.issue.IssueService;
import com.atlassian.jira.bc.issue.comment.CommentService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.mau.MauEventService;
import com.atlassian.jira.issue.IssueFactory;
import com.atlassian.jira.issue.IssueInputParameters;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.TemporaryAttachmentsMonitorLocator;
import com.atlassian.jira.issue.comments.Comment;
import com.atlassian.jira.security.xsrf.RequiresXsrfCheck;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.util.JiraUrlCodec;
import com.atlassian.jira.web.action.issue.CreateIssueDetails;
import com.atlassian.jira.web.action.issue.IssueCreationHelperBean;


public class ComDescCreateIssueDetails extends CreateIssueDetails {

    private IssueService issueService;
    private CommentService commentService;

    public ComDescCreateIssueDetails(IssueFactory issueFactory, IssueCreationHelperBean issueCreationHelperBean, IssueService issueService, TemporaryAttachmentsMonitorLocator temporaryAttachmentsMonitorLocator) {
        super(issueFactory, issueCreationHelperBean, issueService, temporaryAttachmentsMonitorLocator);
        this.issueService = issueService;
    }

    @Override
    @RequiresXsrfCheck
    protected String doExecute() throws Exception {
        String var1;
        try {
            this.createIssue();
            if(this.hasAnyErrors()) {
                var1 = "error";
                return var1;
            }

            var1 = this.doPostCreationTasks();
        } catch (Exception var6) {
            this.log.error(var6, var6);
            this.addErrorMessage(var6.getMessage() != null?var6.getMessage(): ExceptionUtils.getFullStackTrace(var6));
            String var2 = "error";
            return var2;
        } finally {
            ((MauEventService)ComponentAccessor.getComponent(MauEventService.class)).setApplicationForThreadBasedOnProject(this.getProject());
        }

        return var1;
    }

    @Override
    protected String doPostCreationTasks() throws Exception{
        
        commentService = ComponentAccessor.getComponent(CommentService.class);
        Comment comment1 = addComment("First coment!");

        //from CreateIssueDetails.class
        String issueKey = JiraUrlCodec.encode(this.getKey());
        if(this.isIssueValid()) {
            return this.getRedirect("/browse/" + issueKey);
        } else {
            this.errorMessages.clear();
            return this.getRedirect("CantBrowseCreatedIssue.jspa?issueKey=" + issueKey);
        }
    }

    private Comment addComment(String commentString, MutableIssue issue, ApplicationUser user) {
        CommentService.CommentParameters commentParams = new CommentService.CommentParameters.CommentParametersBuilder()
                .issue(issue).body(commentString).build();
        CommentService.CommentCreateValidationResult commentResult = this.commentService.validateCommentCreate(user, commentParams);
        return this.commentService.create(user, commentResult, true);
    }
}

So, I tried to change this code, using java.lang.Object instead of 

class="com.atlassian.jira.web.action.issue.CreateIssueDetails"

in webwork and so on. But after filling the fields at http:/[jira]/secure/CreateIssue.jspa?pid=10000&issuetype=10000 and pressing Create, I am redirected to http:/[jira]/secure/CreateIssueDetails.jspa getting a code 404. I do not understand why it doesn't go to http:/[jira]/secure/browse/<issue_name>, but to http:/[jira]/secure/<alias>.jspa. Thanks for responses.

 

1 answer

Hi,

I think the probem is in your XM plugin definition of your action

 

Try to see this link maybe it can give you some help

http://www.j-tricks.com/tutorials/extending-jira-actions

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

416 views 7 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you