[TASK] Full coding style clean up
This commit is contained in:
@@ -36,9 +36,8 @@ import net.sourceforge.plantuml.SourceStringReader;
|
|||||||
import net.sourceforge.plantuml.StringUtils;
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delegates the diagram generation from the UML source and
|
* Delegates the diagram generation from the UML source and the filling of the HTTP response with the diagram in the
|
||||||
* the filling of the HTTP response with the diagram in the right format.
|
* right format. Its own responsibility is to produce the right HTTP headers.
|
||||||
* Its own responsibility is to produce the right HTTP headers.
|
|
||||||
*/
|
*/
|
||||||
class DiagramResponse {
|
class DiagramResponse {
|
||||||
private HttpServletResponse response;
|
private HttpServletResponse response;
|
||||||
@@ -57,7 +56,6 @@ class DiagramResponse {
|
|||||||
format = f;
|
format = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void sendDiagram(String uml) throws IOException {
|
void sendDiagram(String uml) throws IOException {
|
||||||
long today = System.currentTimeMillis();
|
long today = System.currentTimeMillis();
|
||||||
if (StringUtils.isDiagramCacheable(uml)) {
|
if (StringUtils.isDiagramCacheable(uml)) {
|
||||||
@@ -78,5 +76,4 @@ class DiagramResponse {
|
|||||||
return contentType.get(format);
|
return contentType.get(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ import HTTPClient.ParseException;
|
|||||||
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 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 startumlPattern = Pattern.compile("/\\w+/start/(.*)");
|
||||||
private static final Pattern proxyPattern = Pattern.compile("/\\w+/proxy/((\\d+)/)?((\\w+)/)?(http://.*)");
|
private static final Pattern proxyPattern = Pattern.compile("/\\w+/proxy/((\\d+)/)?((\\w+)/)?(http://.*)");
|
||||||
private static final Pattern oldStartumlPattern = Pattern.compile("/\\w+/uml/startuml/(.*)");
|
private static final Pattern oldStartumlPattern = Pattern.compile("/\\w+/uml/startuml/(.*)");
|
||||||
|
|||||||
@@ -56,8 +56,7 @@ public class ProxyServlet extends HttpServlet {
|
|||||||
private String format;
|
private String format;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
||||||
throws IOException, ServletException {
|
|
||||||
|
|
||||||
final String uri = request.getRequestURI();
|
final String uri = request.getRequestURI();
|
||||||
|
|
||||||
|
|||||||
@@ -37,15 +37,13 @@ import net.sourceforge.plantuml.code.Transcoder;
|
|||||||
import net.sourceforge.plantuml.code.TranscoderUtil;
|
import net.sourceforge.plantuml.code.TranscoderUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common service servlet to produce diagram from compressed UML source
|
* Common service servlet to produce diagram from compressed UML source contained in the end part of the requested URI.
|
||||||
* contained in the end part of the requested URI.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public abstract class UmlDiagramService extends HttpServlet {
|
public abstract class UmlDiagramService extends HttpServlet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
||||||
throws IOException, ServletException {
|
|
||||||
|
|
||||||
// build the UML source from the compressed request parameter
|
// build the UML source from the compressed request parameter
|
||||||
String text = URLDecoder.decode(getSource(request.getRequestURI()), "UTF-8");
|
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.
|
* 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
|
* @return the compressed UML source
|
||||||
*/
|
*/
|
||||||
abstract public String getSource(String uri);
|
abstract public String getSource(String uri);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives the wished output format of the diagram.
|
* Gives the wished output format of the diagram. This value is used by the DiagramResponse class.
|
||||||
* This value is used by the DiagramResponse class.
|
*
|
||||||
* @return the format
|
* @return the format
|
||||||
*/
|
*/
|
||||||
abstract public FileFormat getOutputFormat();
|
abstract public FileFormat getOutputFormat();
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
public class Welcome extends HttpServlet {
|
public class Welcome extends HttpServlet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
||||||
throws IOException, ServletException {
|
|
||||||
|
|
||||||
// set the sample
|
// set the sample
|
||||||
request.setAttribute("net.sourceforge.plantuml.servlet.decoded", "Bob -> Alice : hello");
|
request.setAttribute("net.sourceforge.plantuml.servlet.decoded", "Bob -> Alice : hello");
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.sourceforge.plantuml.servlet;
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
|
|
||||||
import com.meterware.httpunit.GetMethodWebRequest;
|
import com.meterware.httpunit.GetMethodWebRequest;
|
||||||
import com.meterware.httpunit.WebConversation;
|
import com.meterware.httpunit.WebConversation;
|
||||||
import com.meterware.httpunit.WebRequest;
|
import com.meterware.httpunit.WebRequest;
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import com.meterware.httpunit.WebResponse;
|
|||||||
public class TestForm extends WebappTestCase {
|
public class TestForm extends WebappTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that the welcome page has exactly two form
|
* Verifies that the welcome page has exactly two form with the Bob --> Alice sample
|
||||||
* with the Bob --> Alice sample
|
|
||||||
*/
|
*/
|
||||||
public void testWelcomePage() throws Exception {
|
public void testWelcomePage() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ public class TestProxy extends WebappTestCase {
|
|||||||
*/
|
*/
|
||||||
public void testDefaultProxy() throws Exception {
|
public void testDefaultProxy() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/"
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/" + getServerUrl() + "welcome");
|
||||||
+ getServerUrl() + "welcome");
|
|
||||||
WebResponse response = conversation.getResource(request);
|
WebResponse response = conversation.getResource(request);
|
||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
||||||
@@ -39,8 +38,7 @@ public class TestProxy extends WebappTestCase {
|
|||||||
|
|
||||||
public void testProxyWithFormat() throws Exception {
|
public void testProxyWithFormat() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/svg/"
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/svg/" + getServerUrl() + "welcome");
|
||||||
+ getServerUrl() + "welcome");
|
|
||||||
WebResponse response = conversation.getResource(request);
|
WebResponse response = conversation.getResource(request);
|
||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import com.meterware.httpunit.*;
|
|||||||
public class TestUtils {
|
public class TestUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the URL of the PlantUMLServlet, deployed on the testing web server
|
* Return the URL of the PlantUMLServlet, deployed on the testing web server in the following form
|
||||||
* in the following form http://server/contextroot/
|
* http://server/contextroot/ Note the trailing slash (/)
|
||||||
* Note the trailing slash (/)
|
*
|
||||||
* @return the URL
|
* @return the URL
|
||||||
*/
|
*/
|
||||||
public static String getServerUrl() {
|
public static String getServerUrl() {
|
||||||
@@ -18,12 +18,14 @@ public class TestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try getting a response for the given Conversation and Request
|
* Try getting a response for the given Conversation and Request show an error message if a 404 error appears
|
||||||
* show an error message if a 404 error appears
|
*
|
||||||
* @param conversation - the conversation to use
|
* @param conversation
|
||||||
|
* - the conversation to use
|
||||||
* @param request
|
* @param request
|
||||||
* @return the response
|
* @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 {
|
public static WebResponse tryGetResponse(WebConversation conversation, WebRequest request) throws Exception {
|
||||||
WebResponse response = null;
|
WebResponse response = null;
|
||||||
@@ -37,4 +39,3 @@ public class TestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user