mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-07 17:48:35 +00:00
ATS-213 : Transformers should have unique option name
This commit is contained in:
@@ -28,8 +28,8 @@ src/main/java/org/alfresco/transformer/Application.java
|
||||
<tr><td><div style="text-align:right">targetFilename *</div></td><td><input type="text" name="targetFilename" value="" /></td></tr>
|
||||
<tr><td><div style="text-align:right">width</div></td><td><input type="text" name="width" value="" /></td></tr>
|
||||
<tr><td><div style="text-align:right">height</div></td><td><input type="text" name="height" value="" /></td></tr>
|
||||
<tr><td><div style="text-align:right">allowEnlargement</div></td><td><input type="checkbox" name="allowEnlargement" value="true" /></td></tr>
|
||||
<tr><td><div style="text-align:right">maintainAspectRatio</div></td><td><input type="checkbox" name="maintainAspectRatio" value="true" /></td></tr>
|
||||
<tr><td><div style="text-align:right">allowPdfEnlargement</div></td><td><input type="checkbox" name="allowPdfEnlargement" value="true" /></td></tr>
|
||||
<tr><td><div style="text-align:right">maintainPdfAspectRatio</div></td><td><input type="checkbox" name="maintainPdfAspectRatio" value="true" /></td></tr>
|
||||
<tr><td><div style="text-align:right">page</div></td><td><input type="text" name="page" value="" /></td></tr>
|
||||
<tr><td><div style="text-align:right">timeout</div></td><td><input type="text" name="timeout" value="" /></td></tr>
|
||||
<tr><td></td><td><input type="submit" value="Transform" /></td></tr>
|
||||
@@ -59,8 +59,8 @@ public class AlfrescoPdfRendererController extends AbstractTransformerController
|
||||
@RequestParam("targetFilename") String targetFilename,
|
||||
@RequestParam(value = "width", required = false) Integer width,
|
||||
@RequestParam(value = "height", required = false) Integer height,
|
||||
@RequestParam(value = "allowEnlargement", required = false) Boolean allowEnlargement,
|
||||
@RequestParam(value = "maintainAspectRatio", required = false) Boolean maintainAspectRatio,
|
||||
@RequestParam(value = "allowPdfEnlargement", required = false) Boolean allowPdfEnlargement,
|
||||
@RequestParam(value = "maintainPdfAspectRatio", required = false) Boolean maintainPdfAspectRatio,
|
||||
@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "timeout", required = false) Long timeout)
|
||||
{
|
||||
@@ -79,11 +79,11 @@ public class AlfrescoPdfRendererController extends AbstractTransformerController
|
||||
{
|
||||
args.add("--height=" + height);
|
||||
}
|
||||
if (allowEnlargement != null && allowEnlargement)
|
||||
if (allowPdfEnlargement != null && allowPdfEnlargement)
|
||||
{
|
||||
args.add("--allow-enlargement");
|
||||
}
|
||||
if (maintainAspectRatio != null && maintainAspectRatio)
|
||||
if (maintainPdfAspectRatio != null && maintainPdfAspectRatio)
|
||||
{
|
||||
args.add("--maintain-aspect-ratio");
|
||||
}
|
||||
|
@@ -8,32 +8,24 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.transformer.exceptions.TransformException;
|
||||
import org.alfresco.util.exec.RuntimeExec;
|
||||
import org.alfresco.util.exec.RuntimeExec.ExecutionResult;
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class AbstractCommandExecutor implements CommandExecutor
|
||||
{
|
||||
private RuntimeExec transformCommand = createTransformCommand();
|
||||
private RuntimeExec checkCommand = createCheckCommand();
|
||||
private final RuntimeExec transformCommand = createTransformCommand();
|
||||
private final RuntimeExec checkCommand = createCheckCommand();
|
||||
|
||||
protected abstract RuntimeExec createTransformCommand();
|
||||
|
||||
protected abstract RuntimeExec createCheckCommand();
|
||||
|
||||
// todo remove these setters and and make the fields final
|
||||
public void setTransformCommand(RuntimeExec re) {
|
||||
transformCommand = re;
|
||||
}
|
||||
|
||||
public void setCheckCommand(RuntimeExec re) {
|
||||
checkCommand = re;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Map<String, String> properties, File targetFile, Long timeout)
|
||||
{
|
||||
timeout = timeout != null && timeout > 0 ? timeout : 0;
|
||||
RuntimeExec.ExecutionResult result = transformCommand.execute(properties, timeout);
|
||||
final ExecutionResult result = transformCommand.execute(properties, timeout);
|
||||
|
||||
if (result.getExitValue() != 0 && result.getStdErr() != null && result.getStdErr().length() > 0)
|
||||
{
|
||||
@@ -51,24 +43,23 @@ public abstract class AbstractCommandExecutor implements CommandExecutor
|
||||
@Override
|
||||
public String version()
|
||||
{
|
||||
String version = "Version not checked";
|
||||
if (checkCommand != null)
|
||||
{
|
||||
RuntimeExec.ExecutionResult result = checkCommand.execute();
|
||||
final ExecutionResult result = checkCommand.execute();
|
||||
if (result.getExitValue() != 0 && result.getStdErr() != null && result.getStdErr().length() > 0)
|
||||
{
|
||||
throw new TransformException(INTERNAL_SERVER_ERROR.value(),
|
||||
"Transformer version check exit code was not 0: \n" + result);
|
||||
}
|
||||
|
||||
version = result.getStdOut().trim();
|
||||
final String version = result.getStdOut().trim();
|
||||
if (version.isEmpty())
|
||||
{
|
||||
throw new TransformException(INTERNAL_SERVER_ERROR.value(),
|
||||
"Transformer version check failed to create any output");
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
return version;
|
||||
return "Version not checked";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user