1
0
mirror of https://github.com/octoleo/plantuml-server.git synced 2024-06-16 07:02:23 +00:00

[TASK] Full coding style clean up

This commit is contained in:
Maxime Sinclair 2013-07-10 17:07:24 +02:00
parent ded3a5578a
commit ce168633ad
14 changed files with 130 additions and 137 deletions

View File

@ -36,9 +36,8 @@ import net.sourceforge.plantuml.SourceStringReader;
import net.sourceforge.plantuml.StringUtils;
/**
* Delegates the diagram generation from the UML source and
* the filling of the HTTP response with the diagram in the right format.
* Its own responsibility is to produce the right HTTP headers.
* Delegates the diagram generation from the UML source and the filling of the HTTP response with the diagram in the
* right format. Its own responsibility is to produce the right HTTP headers.
*/
class DiagramResponse {
private HttpServletResponse response;
@ -57,7 +56,6 @@ class DiagramResponse {
format = f;
}
void sendDiagram(String uml) throws IOException {
long today = System.currentTimeMillis();
if (StringUtils.isDiagramCacheable(uml)) {
@ -78,5 +76,4 @@ class DiagramResponse {
return contentType.get(format);
}
}

View File

@ -64,7 +64,8 @@ import HTTPClient.ParseException;
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 diagram
private static final Pattern encodedPattern = Pattern.compile("^[a-zA-Z0-9\\-\\_]+$"); // Format of a compressed
// diagram
private static final Pattern startumlPattern = Pattern.compile("/\\w+/start/(.*)");
private static final Pattern proxyPattern = Pattern.compile("/\\w+/proxy/((\\d+)/)?((\\w+)/)?(http://.*)");
private static final Pattern oldStartumlPattern = Pattern.compile("/\\w+/uml/startuml/(.*)");

View File

@ -56,8 +56,7 @@ public class ProxyServlet extends HttpServlet {
private String format;
@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();

View File

@ -37,15 +37,13 @@ import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
/**
* Common service servlet to produce diagram from compressed UML source
* contained in the end part of the requested URI.
* Common service servlet to produce diagram from compressed UML source contained in the end part of the requested URI.
*/
@SuppressWarnings("serial")
public abstract class UmlDiagramService extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// build the UML source from the compressed request parameter
String text = URLDecoder.decode(getSource(request.getRequestURI()), "UTF-8");
@ -79,14 +77,16 @@ public abstract class UmlDiagramService extends HttpServlet {
/**
* Extracts the compressed UML source from the HTTP URI.
* @param uri the complete URI as returned by request.getRequestURI()
*
* @param uri
* the complete URI as returned by request.getRequestURI()
* @return the compressed UML source
*/
abstract public String getSource(String uri);
/**
* Gives the wished output format of the diagram.
* This value is used by the DiagramResponse class.
* Gives the wished output format of the diagram. This value is used by the DiagramResponse class.
*
* @return the format
*/
abstract public FileFormat getOutputFormat();

View File

@ -39,8 +39,7 @@ import javax.servlet.http.HttpServletResponse;
public class Welcome extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// set the sample
request.setAttribute("net.sourceforge.plantuml.servlet.decoded", "Bob -> Alice : hello");

View File

@ -1,6 +1,5 @@
package net.sourceforge.plantuml.servlet;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;

View File

@ -9,8 +9,7 @@ import com.meterware.httpunit.WebResponse;
public class TestForm extends WebappTestCase {
/**
* Verifies that the welcome page has exactly two form
* with the Bob --> Alice sample
* Verifies that the welcome page has exactly two form with the Bob --> Alice sample
*/
public void testWelcomePage() throws Exception {
WebConversation conversation = new WebConversation();

View File

@ -15,8 +15,7 @@ public class TestProxy extends WebappTestCase {
*/
public void testDefaultProxy() throws Exception {
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/"
+ getServerUrl() + "welcome");
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/" + getServerUrl() + "welcome");
WebResponse response = conversation.getResource(request);
// Analyze response
// Verifies the Content-Type header
@ -39,8 +38,7 @@ public class TestProxy extends WebappTestCase {
public void testProxyWithFormat() throws Exception {
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/svg/"
+ getServerUrl() + "welcome");
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/svg/" + getServerUrl() + "welcome");
WebResponse response = conversation.getResource(request);
// Analyze response
// Verifies the Content-Type header

View File

@ -8,9 +8,9 @@ import com.meterware.httpunit.*;
public class TestUtils {
/**
* Return the URL of the PlantUMLServlet, deployed on the testing web server
* in the following form http://server/contextroot/
* Note the trailing slash (/)
* Return the URL of the PlantUMLServlet, deployed on the testing web server in the following form
* http://server/contextroot/ Note the trailing slash (/)
*
* @return the URL
*/
public static String getServerUrl() {
@ -18,12 +18,14 @@ public class TestUtils {
}
/**
* Try getting a response for the given Conversation and Request
* show an error message if a 404 error appears
* @param conversation - the conversation to use
* Try getting a response for the given Conversation and Request show an error message if a 404 error appears
*
* @param conversation
* - the conversation to use
* @param request
* @return the response
* @throws an Exception if getting the response fails
* @throws an
* Exception if getting the response fails
*/
public static WebResponse tryGetResponse(WebConversation conversation, WebRequest request) throws Exception {
WebResponse response = null;
@ -37,4 +39,3 @@ public class TestUtils {
}
}