Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Change "Issue can't be viewed" page via custom plugin

Vasil'ev Nickolay
Contributor
May 6, 2018

Is there any way to change the "Issue can't be viewed" page via custom plugin? I want to add simple link on this page or directly redirect to another page. 
There was some kind of solution for this problem, but it crashes the JIRA. 

Jira versoin: 7.5.3#75008 (server).

2 answers

1 accepted

1 vote
Answer accepted
Vasil'ev Nickolay
Contributor
May 10, 2018

The one way to change "Issue can't be viewed" page is to implement custom servlet-filter plugin. Credits goes to @Alexey Matveev for an original idea.

I've come with next <servlet-filter> declaration:

 <servlet-filter name="My Servlet Filter" i18n-name-key="my-servlet-filter.name" key="my-servlet-filter" class="ru.temp.servlet.filter.MyServletFilter" location="before-decoration" weight="100">
<description key="my-servlet-filter.description">The My Servlet Filter Plugin</description>
<url-pattern>/browse/*</url-pattern>
</servlet-filter>

The most important things in this declaration is:

  1. location = "before-decoration". Default "before-dispatch" location is not suitable, because filter is never triggered that way - as mentioned in problems here and here, some URL's just can't be intercepted with custom servlet filter with this type of location. "before-login" and "after-encoding" is too early (no content in response can't be found yet).
  1. url-pattern: /browse/* . I'm not sure on this one, but it seems there's no special inner path for an "Issue can't be viewed" error page. With this pattern filter is triggered on any issue page, even found one. Additional research may be appropriate.

Also, you may find these links useful:

  1. Example of how to replace content in servlet filter;
  2. How to set up encoding when output resulting page:
    response.setCharacterEncoding(response.getCharacterEncoding()); // You can preserve original response encoding
    response.getWriter().write(out);
1 vote
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 6, 2018
Vasil'ev Nickolay
Contributor
May 6, 2018

Sounds like a solution, thank you.
There's no uniform URL for an "Issue can't be viewed" page though - I'm not sure, if filter may be applied specifically to this page, instead of all "https//jira/browse/*" pages. 

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 6, 2018

I did not try it but try to attach it to the browse page and see how it works. Or try to attach it to the error page. And have a look at the result.

Vasil'ev Nickolay
Contributor
May 7, 2018

I'll try and will report results here.

Vasil'ev Nickolay
Contributor
May 8, 2018

Well, it seems it's not going to be easy. 
As mentioned in problem here and also here, some URL's just can't be intercepted with custom servlet filter. 

I've tried to implement my own filter with a logging of init() and doFilter() methods, but it only logs init() method (i.e. filter is only initialized but never called). 
Url-pattern is :

/browse/*

 

Vasil'ev Nickolay
Contributor
May 8, 2018

UPDATE: change of filter location to after-encoding helped, going to explore on that one.

UPDATE 2: setting filter location to before-decoration seems to intercept just at right time.

Vasil'ev Nickolay
Contributor
May 8, 2018

Solution worked. Thank you.
Two things which helped me: 

  1. Example of how to replace content in servlet filter;
  2. How to set up encoding when output resulting page:
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(out);
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2018

I am glad to hear it. Could you post here what was your <servlet-filter> decalration in the atlassian-plugin.xml?

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2018

Or you can post your own answer and accept it. It would let other people with similair question to find your answer.

Suggest an answer

Log in or Sign up to answer