| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.itracker.web.taglib; |
| 20 |
|
|
| 21 |
|
import java.net.MalformedURLException; |
| 22 |
|
import java.util.Locale; |
| 23 |
|
|
| 24 |
|
import javax.servlet.http.HttpSession; |
| 25 |
|
import javax.servlet.jsp.JspException; |
| 26 |
|
import javax.servlet.jsp.tagext.BodyTagSupport; |
| 27 |
|
|
| 28 |
|
import org.apache.oro.text.regex.MalformedPatternException; |
| 29 |
|
import org.apache.oro.text.regex.Pattern; |
| 30 |
|
import org.apache.oro.text.regex.PatternCompiler; |
| 31 |
|
import org.apache.oro.text.regex.Perl5Compiler; |
| 32 |
|
import org.apache.oro.text.regex.Perl5Matcher; |
| 33 |
|
import org.apache.oro.text.regex.Perl5Substitution; |
| 34 |
|
import org.apache.oro.text.regex.Util; |
| 35 |
|
import org.apache.struts.taglib.TagUtils; |
| 36 |
|
import org.itracker.core.resources.ITrackerResources; |
| 37 |
|
import org.itracker.services.util.HTMLUtilities; |
| 38 |
|
import org.itracker.services.util.ProjectUtilities; |
| 39 |
|
import org.itracker.web.util.Constants; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
|
|
|
| 0% |
Uncovered Elements: 91 (91) |
Complexity: 29 |
Complexity Density: 0.52 |
|
| 49 |
|
public class FormatHistoryEntryTag extends BodyTagSupport { |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
private static final long serialVersionUID = 1L; |
| 54 |
|
private static Perl5Matcher matcher = new Perl5Matcher(); |
| 55 |
|
private static PatternCompiler compiler = new Perl5Compiler(); |
| 56 |
|
|
| 57 |
|
private String text = null; |
| 58 |
|
private String issueNamesKey = "itracker.web.issuenames"; |
| 59 |
|
private String forward ="viewissue"; |
| 60 |
|
private String paramName = "id"; |
| 61 |
|
private String paramValue = "$2"; |
| 62 |
|
private String textPattern = "$1 $2"; |
| 63 |
|
private String styleClass = "history"; |
| 64 |
|
private int projectOptions = 0; |
| 65 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 66 |
0
|
public String getForward() {... |
| 67 |
0
|
return forward; |
| 68 |
|
} |
| 69 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 70 |
0
|
public void setForward(String value) {... |
| 71 |
0
|
forward = value; |
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 74 |
0
|
public String getParamName() {... |
| 75 |
0
|
return paramName; |
| 76 |
|
} |
| 77 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 78 |
0
|
public void setParamName(String value) {... |
| 79 |
0
|
paramName = value; |
| 80 |
|
} |
| 81 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 82 |
0
|
public Object getParamValue() {... |
| 83 |
0
|
return paramValue; |
| 84 |
|
} |
| 85 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 1 |
|
| 86 |
0
|
public void setParamValue(Object value) {... |
| 87 |
0
|
paramValue = (value != null ? value.toString() : null); |
| 88 |
|
} |
| 89 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 90 |
0
|
public String getIssueNamesKey() {... |
| 91 |
0
|
return issueNamesKey; |
| 92 |
|
} |
| 93 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
0
|
public void setIssueNamesKey(String value) {... |
| 95 |
0
|
issueNamesKey = value; |
| 96 |
|
} |
| 97 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 98 |
0
|
public String getTextPattern() {... |
| 99 |
0
|
return textPattern; |
| 100 |
|
} |
| 101 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 102 |
0
|
public void setTextPattern(String value) {... |
| 103 |
0
|
textPattern = value; |
| 104 |
|
} |
| 105 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 106 |
0
|
public String getStyleClass() {... |
| 107 |
0
|
return styleClass; |
| 108 |
|
} |
| 109 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
0
|
public void setStyleClass(String value) {... |
| 111 |
0
|
styleClass = value; |
| 112 |
|
} |
| 113 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 114 |
0
|
public int getProjectOptions() {... |
| 115 |
0
|
return projectOptions; |
| 116 |
|
} |
| 117 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 118 |
0
|
public void setProjectOptions(int value) {... |
| 119 |
0
|
projectOptions = value; |
| 120 |
|
} |
| 121 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 122 |
0
|
public int doStartTag() throws JspException {... |
| 123 |
0
|
text = null; |
| 124 |
0
|
return EVAL_BODY_BUFFERED; |
| 125 |
|
} |
| 126 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 127 |
0
|
public int doAfterBody() throws JspException {... |
| 128 |
0
|
if(bodyContent != null) { |
| 129 |
0
|
String value = bodyContent.getString().trim(); |
| 130 |
0
|
if(value.length() > 0) { |
| 131 |
0
|
text = value; |
| 132 |
|
} |
| 133 |
|
} |
| 134 |
0
|
return SKIP_BODY; |
| 135 |
|
} |
| 136 |
|
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 9 |
Complexity Density: 0.35 |
|
| 137 |
0
|
public int doEndTag() throws JspException {... |
| 138 |
0
|
if(text != null) { |
| 139 |
0
|
Locale locale = null; |
| 140 |
|
|
| 141 |
0
|
HttpSession session = pageContext.getSession(); |
| 142 |
0
|
if(session != null) { |
| 143 |
0
|
locale = (Locale) session.getAttribute(Constants.LOCALE_KEY); |
| 144 |
|
} |
| 145 |
|
|
| 146 |
0
|
if(ProjectUtilities.hasOption(ProjectUtilities.OPTION_SURPRESS_HISTORY_HTML, projectOptions)) { |
| 147 |
0
|
text = HTMLUtilities.removeMarkup(text); |
| 148 |
0
|
} else if(ProjectUtilities.hasOption(ProjectUtilities.OPTION_LITERAL_HISTORY_HTML, projectOptions)) { |
| 149 |
0
|
text = HTMLUtilities.escapeTags(text); |
| 150 |
|
} else { |
| 151 |
0
|
text = HTMLUtilities.newlinesToBreaks(text); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
0
|
try { |
| 155 |
0
|
Pattern pattern = compiler.compile("(" + ITrackerResources.getString(issueNamesKey, locale) + ")\\s(\\d+)", Perl5Compiler.CASE_INSENSITIVE_MASK); |
| 156 |
|
|
| 157 |
0
|
StringBuffer buf = new StringBuffer("<a href=\""); |
| 158 |
0
|
try { |
| 159 |
|
|
| 160 |
0
|
buf.append(TagUtils.getInstance().computeURL(pageContext, forward, null, null, null, null, null, null, false)); |
| 161 |
|
} catch(MalformedURLException murle) { |
| 162 |
0
|
buf.append(forward); |
| 163 |
|
} |
| 164 |
0
|
buf.append("?" + paramName + "=" + paramValue + "\" "); |
| 165 |
0
|
buf.append("class=\"" + styleClass + "\">"); |
| 166 |
0
|
buf.append(textPattern); |
| 167 |
0
|
buf.append("</a>"); |
| 168 |
|
|
| 169 |
0
|
text = Util.substitute(matcher, pattern, new Perl5Substitution(buf.toString()), text, Util.SUBSTITUTE_ALL); |
| 170 |
|
} catch(MalformedPatternException mpe) { |
| 171 |
|
} |
| 172 |
|
|
| 173 |
0
|
if(ProjectUtilities.hasOption(ProjectUtilities.OPTION_SURPRESS_HISTORY_HTML, projectOptions) || |
| 174 |
|
ProjectUtilities.hasOption(ProjectUtilities.OPTION_LITERAL_HISTORY_HTML, projectOptions)) { |
| 175 |
0
|
text = "<pre>" + text + "</pre>"; |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
|
| 179 |
0
|
TagUtils.getInstance().write(pageContext, text); |
| 180 |
|
} |
| 181 |
|
|
| 182 |
0
|
clearState(); |
| 183 |
0
|
return (EVAL_PAGE); |
| 184 |
|
} |
| 185 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 186 |
0
|
public void release() {... |
| 187 |
0
|
super.release(); |
| 188 |
0
|
clearState(); |
| 189 |
|
} |
| 190 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 191 |
0
|
private void clearState() {... |
| 192 |
0
|
text = null; |
| 193 |
0
|
issueNamesKey = "itracker.web.issuenames"; |
| 194 |
0
|
forward ="viewissue"; |
| 195 |
0
|
paramName = "id"; |
| 196 |
0
|
paramValue = "$2"; |
| 197 |
0
|
textPattern = "$1 $2"; |
| 198 |
0
|
styleClass = "history"; |
| 199 |
|
} |
| 200 |
|
} |