[FEATURE] Checkstyle violations fail the Build

This commit is contained in:
maximesinclair
2014-02-15 19:04:30 +01:00
parent d51bbd4d13
commit 9401ab4a61
8 changed files with 44 additions and 13 deletions

View File

@@ -44,13 +44,13 @@ import net.sourceforge.plantuml.servlet.utility.NullOutputStream;
class DiagramResponse {
private HttpServletResponse response;
private FileFormat format;
private static final Map<FileFormat, String> contentType;
private static final Map<FileFormat, String> CONTENT_TYPE;
static {
Map<FileFormat, String> map = new HashMap<FileFormat, String>();
map.put(FileFormat.PNG, "image/png");
map.put(FileFormat.SVG, "image/svg+xml");
map.put(FileFormat.UTXT, "text/plain;charset=UTF-8");
contentType = Collections.unmodifiableMap(map);
CONTENT_TYPE = Collections.unmodifiableMap(map);
}
DiagramResponse(HttpServletResponse r, FileFormat f) {
@@ -92,7 +92,7 @@ class DiagramResponse {
}
private String getContentType() {
return contentType.get(format);
return CONTENT_TYPE.get(format);
}
}

View File

@@ -52,7 +52,7 @@ import net.sourceforge.plantuml.SourceStringReader;
@SuppressWarnings("serial")
public class OldProxyServlet extends HttpServlet {
private static final Pattern proxyPattern = Pattern.compile("/\\w+/proxy/((\\d+)/)?((\\w+)/)?(http://.*)");
private static final Pattern PROXY_PATTERN = Pattern.compile("/\\w+/proxy/((\\d+)/)?((\\w+)/)?(http://.*)");
private String format;
@Override
@@ -60,7 +60,7 @@ public class OldProxyServlet extends HttpServlet {
final String uri = request.getRequestURI();
Matcher proxyMatcher = proxyPattern.matcher(uri);
Matcher proxyMatcher = PROXY_PATTERN.matcher(uri);
if (proxyMatcher.matches()) {
String num = proxyMatcher.group(2); // Optional number of the diagram source
format = proxyMatcher.group(4); // Expected format of the generated diagram

View File

@@ -60,16 +60,16 @@ import net.sourceforge.plantuml.api.PlantumlUtils;
@SuppressWarnings("serial")
public class PlantUmlServlet extends HttpServlet {
private static final Pattern urlPattern = Pattern.compile(".*/(.*)"); // Last part of the URL
private static final Pattern encodedPattern = Pattern.compile("^[a-zA-Z0-9\\-\\_]+$"); // Format of a compressed
private static final Pattern URL_PATTERN = Pattern.compile(".*/(.*)"); // Last part of the URL
private static final Pattern ENCODED_PATTERN = Pattern.compile("^[a-zA-Z0-9\\-\\_]+$"); // Format of a compressed
// diagram
private static final Pattern startumlPattern = Pattern.compile("/\\w+/start/(.*)");
private static final Pattern START_PATTERN = Pattern.compile("/\\w+/start/(.*)");
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
final String uri = request.getRequestURI();
Matcher startumlMatcher = startumlPattern.matcher(uri);
Matcher startumlMatcher = START_PATTERN.matcher(uri);
if (startumlMatcher.matches()) {
System.out.println("PlantUML WARNING This syntax is deprecated.");
String source = startumlMatcher.group(1);
@@ -92,12 +92,12 @@ public class PlantUmlServlet extends HttpServlet {
// the URL form has been submitted
if (url != null && !url.trim().isEmpty()) {
// Catch the last part of the URL if necessary
Matcher m1 = urlPattern.matcher(url);
Matcher m1 = URL_PATTERN.matcher(url);
if (m1.find()) {
url = m1.group(1);
}
// Check it's a valid compressed text
Matcher m2 = encodedPattern.matcher(url);
Matcher m2 = ENCODED_PATTERN.matcher(url);
if (m2.find()) {
url = m2.group(0);
text = transcoder.decode(url);

View File

@@ -76,4 +76,9 @@ public class UmlExtractor {
return uml;
}
protected UmlExtractor() {
// prevents calls from subclass
throw new UnsupportedOperationException();
}
}