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:
@@ -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