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:
parent
ded3a5578a
commit
ce168633ad
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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/(.*)");
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.sourceforge.plantuml.servlet;
|
||||
|
||||
|
||||
import com.meterware.httpunit.GetMethodWebRequest;
|
||||
import com.meterware.httpunit.WebConversation;
|
||||
import com.meterware.httpunit.WebRequest;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user