IssuezillaLinkPlugin

Revision as of 09:20, 28 January 2010 by Newacct (Talk | contribs)

Issuezilla Link Plugin for JSPWiki

Motivation

It is painful to create links to NetBeans issuezilla as wiki links
 [http://www.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:

[{IZNum=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

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=" + Integer.toString(issueNumber);
                issueHyperLink = "<a class=\"external\" href='" + issueURL + "'>Issue " + issueNumber + "</a>";
            } catch (NumberFormatException e) {
                issueHyperLink = "<b>IZ usage:</b><br> <pre>[{IZNum=123123}]

Where 123123 is valid NetBeans issue number.";
           }
       } else {
issueHyperLink = "IZ usage:
[{IZNum=123123}]

Where 123123 is valid NetBeans issue number.";
       }
       return issueHyperLink;
   }

} </pre>

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