mirror of
https://github.com/octoleo/plantuml-server.git
synced 2025-01-03 13:07:23 +00:00
[FEATURE] Checkstyle violations fail the Build
This commit is contained in:
parent
d51bbd4d13
commit
9401ab4a61
21
pom.xml
21
pom.xml
@ -65,6 +65,27 @@
|
|||||||
<artifactId>maven-site-plugin</artifactId>
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
<version>3.0-beta-3</version>
|
<version>3.0-beta-3</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>2.11</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>validate</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>${basedir}/src/main/config/checkstyle.xml</configLocation>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<consoleOutput>true</consoleOutput>
|
||||||
|
<failsOnError>true</failsOnError>
|
||||||
|
<linkXRef>false</linkXRef>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<reporting>
|
<reporting>
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
Description: none
|
Description: none
|
||||||
-->
|
-->
|
||||||
<module name="Checker">
|
<module name="Checker">
|
||||||
<property name="severity" value="warning"/>
|
<property name="severity" value="error"/>
|
||||||
|
<property name="charset" value="UTF-8"/>
|
||||||
<module name="TreeWalker">
|
<module name="TreeWalker">
|
||||||
<module name="JavadocMethod">
|
<module name="JavadocMethod">
|
||||||
<property name="severity" value="ignore"/>
|
<property name="severity" value="ignore"/>
|
||||||
|
@ -44,13 +44,13 @@ import net.sourceforge.plantuml.servlet.utility.NullOutputStream;
|
|||||||
class DiagramResponse {
|
class DiagramResponse {
|
||||||
private HttpServletResponse response;
|
private HttpServletResponse response;
|
||||||
private FileFormat format;
|
private FileFormat format;
|
||||||
private static final Map<FileFormat, String> contentType;
|
private static final Map<FileFormat, String> CONTENT_TYPE;
|
||||||
static {
|
static {
|
||||||
Map<FileFormat, String> map = new HashMap<FileFormat, String>();
|
Map<FileFormat, String> map = new HashMap<FileFormat, String>();
|
||||||
map.put(FileFormat.PNG, "image/png");
|
map.put(FileFormat.PNG, "image/png");
|
||||||
map.put(FileFormat.SVG, "image/svg+xml");
|
map.put(FileFormat.SVG, "image/svg+xml");
|
||||||
map.put(FileFormat.UTXT, "text/plain;charset=UTF-8");
|
map.put(FileFormat.UTXT, "text/plain;charset=UTF-8");
|
||||||
contentType = Collections.unmodifiableMap(map);
|
CONTENT_TYPE = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagramResponse(HttpServletResponse r, FileFormat f) {
|
DiagramResponse(HttpServletResponse r, FileFormat f) {
|
||||||
@ -92,7 +92,7 @@ class DiagramResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getContentType() {
|
private String getContentType() {
|
||||||
return contentType.get(format);
|
return CONTENT_TYPE.get(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ import net.sourceforge.plantuml.SourceStringReader;
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class OldProxyServlet extends HttpServlet {
|
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;
|
private String format;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -60,7 +60,7 @@ public class OldProxyServlet extends HttpServlet {
|
|||||||
|
|
||||||
final String uri = request.getRequestURI();
|
final String uri = request.getRequestURI();
|
||||||
|
|
||||||
Matcher proxyMatcher = proxyPattern.matcher(uri);
|
Matcher proxyMatcher = PROXY_PATTERN.matcher(uri);
|
||||||
if (proxyMatcher.matches()) {
|
if (proxyMatcher.matches()) {
|
||||||
String num = proxyMatcher.group(2); // Optional number of the diagram source
|
String num = proxyMatcher.group(2); // Optional number of the diagram source
|
||||||
format = proxyMatcher.group(4); // Expected format of the generated diagram
|
format = proxyMatcher.group(4); // Expected format of the generated diagram
|
||||||
|
@ -60,16 +60,16 @@ import net.sourceforge.plantuml.api.PlantumlUtils;
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class PlantUmlServlet extends HttpServlet {
|
public class PlantUmlServlet extends HttpServlet {
|
||||||
|
|
||||||
private static final Pattern urlPattern = Pattern.compile(".*/(.*)"); // Last part of the URL
|
private static final Pattern URL_PATTERN = 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 ENCODED_PATTERN = Pattern.compile("^[a-zA-Z0-9\\-\\_]+$"); // Format of a compressed
|
||||||
// diagram
|
// diagram
|
||||||
private static final Pattern startumlPattern = Pattern.compile("/\\w+/start/(.*)");
|
private static final Pattern START_PATTERN = Pattern.compile("/\\w+/start/(.*)");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
||||||
|
|
||||||
final String uri = request.getRequestURI();
|
final String uri = request.getRequestURI();
|
||||||
Matcher startumlMatcher = startumlPattern.matcher(uri);
|
Matcher startumlMatcher = START_PATTERN.matcher(uri);
|
||||||
if (startumlMatcher.matches()) {
|
if (startumlMatcher.matches()) {
|
||||||
System.out.println("PlantUML WARNING This syntax is deprecated.");
|
System.out.println("PlantUML WARNING This syntax is deprecated.");
|
||||||
String source = startumlMatcher.group(1);
|
String source = startumlMatcher.group(1);
|
||||||
@ -92,12 +92,12 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
// the URL form has been submitted
|
// the URL form has been submitted
|
||||||
if (url != null && !url.trim().isEmpty()) {
|
if (url != null && !url.trim().isEmpty()) {
|
||||||
// Catch the last part of the URL if necessary
|
// Catch the last part of the URL if necessary
|
||||||
Matcher m1 = urlPattern.matcher(url);
|
Matcher m1 = URL_PATTERN.matcher(url);
|
||||||
if (m1.find()) {
|
if (m1.find()) {
|
||||||
url = m1.group(1);
|
url = m1.group(1);
|
||||||
}
|
}
|
||||||
// Check it's a valid compressed text
|
// Check it's a valid compressed text
|
||||||
Matcher m2 = encodedPattern.matcher(url);
|
Matcher m2 = ENCODED_PATTERN.matcher(url);
|
||||||
if (m2.find()) {
|
if (m2.find()) {
|
||||||
url = m2.group(0);
|
url = m2.group(0);
|
||||||
text = transcoder.decode(url);
|
text = transcoder.decode(url);
|
||||||
|
@ -76,4 +76,9 @@ public class UmlExtractor {
|
|||||||
return uml;
|
return uml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected UmlExtractor() {
|
||||||
|
// prevents calls from subclass
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||||||
|
|
||||||
public class ServerUtils {
|
public class ServerUtils {
|
||||||
|
|
||||||
Server server;
|
private Server server;
|
||||||
|
|
||||||
public ServerUtils(boolean start) throws Exception {
|
public ServerUtils(boolean start) throws Exception {
|
||||||
server = new Server(new InetSocketAddress("127.0.0.1", 0));
|
server = new Server(new InetSocketAddress("127.0.0.1", 0));
|
||||||
|
@ -20,4 +20,8 @@ public class TestUtils {
|
|||||||
*/
|
*/
|
||||||
public static final String SEQBOB = "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000";
|
public static final String SEQBOB = "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000";
|
||||||
|
|
||||||
|
protected TestUtils() {
|
||||||
|
// prevents calls from subclass
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user