IssuezillaLinkPlugin

Revision as of 20:52, 7 August 2013 by Skygo (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

Issuezilla Link Plugin for JSPWiki

Motivation

It is painful to create links to NetBeans issuezilla as wiki links
 [https://netbeans.org/issues/show_bug.cgi?id=123456 123456]
It is lot of text that the user has to write down.

Solution

Issuezilla plugin usage is deprecated as netbeans use mediawiki:

[{IZNum=123123}]

A template named iz exists to replace the older one:

{{iz|123123}}

Where 123123 is valid NetBeans issue number. The result will look like link to the issue number 123123

Result: 123456

Test: Issue 123123


Source code

This is the code of the former Issuezilla Plugin.

package nbimport;
 
import com.ecyrd.jspwiki.plugin.WikiPlugin;
import com.ecyrd.jspwiki.WikiContext;
import java.util.Map;
 
public class IZ implements WikiPlugin {
 
    public String execute(WikiContext Context, Map ParameterMap) {
        String issueNumberString = "";
        int issueNumber = 0;
        String issueURL = "";
        String issueHyperLink = "";
        if (ParameterMap != null && ParameterMap.containsKey("num")) {
            try {
                issueNumberString = (String) ParameterMap.get("num");
                issueNumber = Integer.parseInt(issueNumberString); // check if it really is issue number - against HTML injection
                issueURL = "http://www.netbeans.org/issues/show_bug.cgi?id=" + issueNumber;
                issueHyperLink = "<a class=\"external\" href='" + issueURL + "'>Issue " + issueNumber + "</a>";
            } catch (NumberFormatException e) {
                issueHyperLink = "<b>IZ usage:</b><br> <pre>[{IZNum=123123}]</pre><br> Where 123123 is valid NetBeans issue number.";
            }
        } else {
            issueHyperLink = "<b>IZ usage:</b><br> <pre>[{IZNum=123123}]</pre><br> Where 123123 is valid NetBeans issue number.";
        }
        return issueHyperLink;
    }
}
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo