mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
Save point: [skip ci]
* AbstractHttpRequestTest title in pages
This commit is contained in:
@@ -66,6 +66,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -228,16 +229,18 @@ public class TransformController
|
||||
@GetMapping(ENDPOINT_ROOT)
|
||||
public String test(Model model)
|
||||
{
|
||||
return "test";
|
||||
model.addAttribute("title", transformEngine.getTransformEngineName() + " Test Page");
|
||||
return "test"; // display test.html
|
||||
}
|
||||
|
||||
/**
|
||||
* Test UI error page.
|
||||
*/
|
||||
@GetMapping(ENDPOINT_ERROR)
|
||||
public String error()
|
||||
public String error(Model model)
|
||||
{
|
||||
return "error"; // the name of the template
|
||||
model.addAttribute("title", transformEngine.getTransformEngineName() + " Error Page");
|
||||
return "error"; // display error.html
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +255,7 @@ public class TransformController
|
||||
{
|
||||
model.addAttribute("log", log);
|
||||
}
|
||||
return "log"; // the name of the template
|
||||
return "log"; // display log.html
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,8 +401,6 @@ public class TransformController
|
||||
* @param timeout Transformation timeout
|
||||
* @return A transformation reply
|
||||
*/
|
||||
@PostMapping(value = ENDPOINT_TRANSFORM, produces = APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public ResponseEntity<TransformReply> transform(@RequestBody TransformRequest request,
|
||||
@RequestParam(value = "timeout", required = false) Long timeout)
|
||||
{
|
||||
@@ -741,12 +742,6 @@ public class TransformController
|
||||
return customTransformer;
|
||||
}
|
||||
|
||||
public void transformImpl(String transformName, String sourceMimetype, String targetMimetype,
|
||||
Map<String, String> transformOptions, File sourceFile, File targetFile)
|
||||
{
|
||||
//javaExecutor.transformExtractOrEmbed(transformName, sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile);
|
||||
}
|
||||
|
||||
@ExceptionHandler(TypeMismatchException.class)
|
||||
public void handleParamsTypeMismatch(HttpServletResponse response, MissingServletRequestParameterException e) throws IOException
|
||||
{
|
||||
@@ -766,18 +761,25 @@ public class TransformController
|
||||
|
||||
logger.error(message, e);
|
||||
LogEntry.setStatusCodeAndMessage(statusCode, message);
|
||||
response.sendError(statusCode, transformEngine.getTransformEngineName() + " - " + message);
|
||||
response.sendError(statusCode, message);
|
||||
}
|
||||
|
||||
@ExceptionHandler(TransformException.class)
|
||||
public void transformExceptionWithMessage(HttpServletResponse response, TransformException e) throws IOException
|
||||
public ModelAndView transformExceptionWithMessage(HttpServletResponse response, TransformException e)
|
||||
throws IOException
|
||||
{
|
||||
final String message = e.getMessage();
|
||||
final int statusCode = e.getStatusCode();
|
||||
|
||||
logger.error(message, e);
|
||||
logger.error(message);
|
||||
long time = LogEntry.setStatusCodeAndMessage(statusCode, message);
|
||||
probeTestTransform.recordTransformTime(time);
|
||||
response.sendError(statusCode, transformEngine.getTransformEngineName() + " - " + message);
|
||||
response.sendError(statusCode, message);
|
||||
|
||||
ModelAndView mav = new ModelAndView();
|
||||
mav.addObject("title", transformEngine.getTransformEngineName() + " Error Page");
|
||||
mav.addObject("message", message);
|
||||
mav.setViewName("error"); // display error.html
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
|
@@ -227,7 +227,7 @@ public class ProbeTestTransform
|
||||
File targetFile = getTargetFile(request);
|
||||
|
||||
String transformName = getTransformerName(sourceFile, sourceMimetype, targetMimetype, transformOptions);
|
||||
controller.transformImpl(transformName, sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile);
|
||||
// controller.transformImpl(transformName, sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile);
|
||||
|
||||
long time = System.currentTimeMillis() - start;
|
||||
String message = "Transform " + time + "ms";
|
||||
|
@@ -2,13 +2,9 @@
|
||||
<body>
|
||||
|
||||
<div>
|
||||
<div th:if="${message} == null">
|
||||
<h2>Error Page</h2>
|
||||
</div>
|
||||
<h2 th:text="${title}"></h2>
|
||||
<div th:if="${message}">
|
||||
<h2 th:text="${message}"></h2>
|
||||
<!-- <h2 th:text="${#strings.substring(message,0,#strings.indexOf(message,' - '))} + ' Error Page'"></h2>-->
|
||||
<!-- <h3 th:text="${#strings.substring(message,#strings.indexOf(message,' - ')+3)}"></h3>-->
|
||||
<h3 th:text="${message}"></h3>
|
||||
</div>
|
||||
<p th:text="${status} + ' - ' + ${error}"></p>
|
||||
</div>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<body>
|
||||
<div>
|
||||
<h2>Test Transformations</h2>
|
||||
<h2 th:text="${title}"></h2>
|
||||
<form method="POST" enctype="multipart/form-data" action="/test">
|
||||
<table>
|
||||
<tr><td><div style="text-align:right">file</div></td><td><input type="file" name="file" /></td></tr>
|
||||
|
@@ -65,7 +65,7 @@ public abstract class AbstractHttpRequestTest
|
||||
{
|
||||
String result = restTemplate.getForObject("http://localhost:" + port + "/", String.class);
|
||||
|
||||
String title = "Test Transformation";
|
||||
String title = getTransformerName() + " Test Page";
|
||||
assertTrue("\"" + title + "\" should be part of the page title", result.contains(title));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class AbstractHttpRequestTest
|
||||
String result = restTemplate.getForObject("http://localhost:" + port + "/log",
|
||||
String.class);
|
||||
|
||||
String title = getTransformerName() + ' ' + "Log";
|
||||
String title = getTransformerName() + " Log";
|
||||
assertTrue("\"" + title + "\" should be part of the page title", result.contains(title));
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ public abstract class AbstractHttpRequestTest
|
||||
String result = restTemplate.getForObject("http://localhost:" + port + "/error",
|
||||
String.class);
|
||||
|
||||
String title = getTransformerName() + ' ' + "Error Page";
|
||||
assertTrue("\"" + title + "\" should be part of the page title", result.contains("Error Page"));
|
||||
String title = getTransformerName() + " Error Page";
|
||||
assertTrue("\"" + title + "\" should be part of the page title", result.contains(title));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,17 +95,10 @@ public abstract class AbstractHttpRequestTest
|
||||
LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
|
||||
parameters.add("targetExtension", ".tmp");
|
||||
|
||||
assertTransformError(false,
|
||||
getTransformerName() + " - Required request part 'file' is not present",
|
||||
assertTransformError(false, "Required request part 'file' is not present",
|
||||
parameters);
|
||||
}
|
||||
|
||||
private void assertMissingParameter(String name)
|
||||
{
|
||||
assertTransformError(true,
|
||||
getTransformerName() + " - Request parameter '" + name + "' is missing", null);
|
||||
}
|
||||
|
||||
protected void assertTransformError(boolean addFile,
|
||||
String errorMessage,
|
||||
LinkedMultiValueMap<String, Object> additionalParams)
|
||||
@@ -138,10 +131,7 @@ public abstract class AbstractHttpRequestTest
|
||||
parameters.add("targetExtension", ".tmp");
|
||||
parameters.add(DIRECT_ACCESS_URL, directUrl);
|
||||
|
||||
assertTransformError(false,
|
||||
getTransformerName() + " - Direct Access Url not found.",
|
||||
parameters);
|
||||
|
||||
assertTransformError(false, "Direct Access Url not found.", parameters);
|
||||
}
|
||||
|
||||
protected void sendTranformationRequest(
|
||||
|
Reference in New Issue
Block a user