本文整理汇总了Java中org.alfresco.util.exec.RuntimeExec.ExecutionResult方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeExec.ExecutionResult方法的具体用法?Java RuntimeExec.ExecutionResult怎么用?Java RuntimeExec.ExecutionResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.util.exec.RuntimeExec
的用法示例。
在下文中一共展示了RuntimeExec.ExecutionResult方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import org.alfresco.util.exec.RuntimeExec; //导入方法依赖的package包/类
public final void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception {
try {
String sourceMimetype = getMimetype(reader);
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
File sourceFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_source_", "." + sourceExtension);
reader.getContent(sourceFile);
String path = sourceFile.getAbsolutePath();
String targetPath = path.substring(0, path.toLowerCase().lastIndexOf(".")) + "_ocr.pdf";
Map<String, String> properties = new HashMap<String, String>(1);
properties.put(VAR_SOURCE, sourceFile.getAbsolutePath());
properties.put(VAR_TARGET, targetPath);
RuntimeExec.ExecutionResult result = obtainExecuter(properties);
if (verbose) {
logger.info("EXIT VALUE: " + result.getExitValue());
logger.info("STDOUT: " + result.getStdOut());
logger.info("STDERR: " + result.getStdErr());
}
if (result.getExitValue() == 143) {
logger.warn(result.getStdErr());
}
else if (result.getExitValue() != 0 && result.getStdErr() != null && result.getStdErr().length() > 0) {
throw new ContentIOException("Failed to perform OCR transformation: \n" + result);
}
File targetFile = new File(targetPath);
writer.putContent(targetFile);
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
示例2: obtainExecuter
import org.alfresco.util.exec.RuntimeExec; //导入方法依赖的package包/类
private RuntimeExec.ExecutionResult obtainExecuter(Map<String, String> properties){
if (serverOS.equals(SERVER_OS_LINUX)) {
return executerLinux.execute(properties);
} else if (serverOS.equals(SERVER_OS_WINDOWS)) {
return executerWindows.execute(properties);
} else {
throw new ContentIOException("Failed to recognize the operative system: \n" + serverOS);
}
}
示例3: test
import org.alfresco.util.exec.RuntimeExec; //导入方法依赖的package包/类
protected void test() {
try {
logger.debug("Testing availability");
RuntimeExec.ExecutionResult result = checkCommand.execute();
available=result.getSuccess();
logger.info("Is OCR available? " + available);
}
catch (Exception e) {
available=false;
logger.warn("Check command [" + checkCommand.getCommand() + "] failed. Registering transform as unavailable for the next " + checkFrequencyInSeconds + " seconds");
}
}
示例4: transformInternal
import org.alfresco.util.exec.RuntimeExec; //导入方法依赖的package包/类
/**
* Transform the image content from the source file to the target file
*/
@Override
protected void transformInternal(File sourceFile, String sourceMimetype,
File targetFile, String targetMimetype, TransformationOptions options) throws Exception
{
Map<String, String> properties = new HashMap<String, String>(5);
// set properties
if (options instanceof ImageTransformationOptions)
{
ImageTransformationOptions imageOptions = (ImageTransformationOptions)options;
CropSourceOptions cropOptions = imageOptions.getSourceOptions(CropSourceOptions.class);
ImageResizeOptions resizeOptions = imageOptions.getResizeOptions();
String commandOptions = imageOptions.getCommandOptions();
if (commandOptions == null)
{
commandOptions = "";
}
// MNT-10882 : JPEG File Format, does not save the alpha (transparency) channel.
if (MimetypeMap.MIMETYPE_IMAGE_JPEG.equalsIgnoreCase(targetMimetype) && isAlphaOptionSupported())
{
commandOptions += " -alpha remove";
}
if (imageOptions.isAutoOrient())
{
commandOptions = commandOptions + " -auto-orient";
}
if (cropOptions != null)
{
commandOptions = commandOptions + " " + getImageCropCommandOptions(cropOptions);
}
if (resizeOptions != null)
{
commandOptions = commandOptions + " " + getImageResizeCommandOptions(resizeOptions);
}
properties.put(KEY_OPTIONS, commandOptions);
}
properties.put(VAR_SOURCE, sourceFile.getAbsolutePath() +
getSourcePageRange(options, sourceMimetype, targetMimetype));
properties.put(VAR_TARGET, targetFile.getAbsolutePath());
// execute the statement
long timeoutMs = options.getTimeoutMs();
RuntimeExec.ExecutionResult result = executer.execute(properties, timeoutMs);
if (result.getExitValue() != 0 && result.getStdErr() != null && result.getStdErr().length() > 0)
{
throw new ContentIOException("Failed to perform ImageMagick transformation: \n" + result);
}
// success
if (logger.isDebugEnabled())
{
logger.debug("ImageMagick executed successfully: \n" + executer);
}
}
示例5: transformInternal
import org.alfresco.util.exec.RuntimeExec; //导入方法依赖的package包/类
/**
* Transform the pdf content from the source file to the target file
*/
private void transformInternal(File sourceFile, String sourceMimetype, File targetFile, String targetMimetype, TransformationOptions options) throws Exception
{
Map<String, String> properties = new HashMap<String, String>(5);
// set properties
if (options instanceof ImageTransformationOptions)
{
ImageTransformationOptions imageOptions = (ImageTransformationOptions) options;
ImageResizeOptions resizeOptions = imageOptions.getResizeOptions();
String commandOptions = imageOptions.getCommandOptions();
if (commandOptions == null)
{
commandOptions = "";
}
if(resizeOptions != null)
{
if (resizeOptions.getHeight() > -1)
{
commandOptions += " --height=" + resizeOptions.getHeight();
}
if (resizeOptions.getWidth() > -1)
{
commandOptions += " --width=" + resizeOptions.getHeight();
}
if (resizeOptions.getAllowEnlargement())
{
commandOptions += " --allow-enlargement";
}
if (resizeOptions.isMaintainAspectRatio())
{
commandOptions += " --maintain-aspect-ratio";
}
}
commandOptions += " --page=" + getSourcePageRange(imageOptions, sourceMimetype, targetMimetype);
properties.put(KEY_OPTIONS, commandOptions);
}
properties.put(VAR_SOURCE, sourceFile.getAbsolutePath());
properties.put(VAR_TARGET, targetFile.getAbsolutePath());
// execute the statement
long timeoutMs = options.getTimeoutMs();
RuntimeExec.ExecutionResult result = executer.execute(properties, timeoutMs);
if (result.getExitValue() != 0 && result.getStdErr() != null && result.getStdErr().length() > 0)
{
throw new ContentIOException("Failed to perform alfresco-pdf-renderer transformation: \n" + result);
}
// success
if (logger.isDebugEnabled())
{
logger.debug("alfresco-pdf-renderer executed successfully: \n" + executer);
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:58,代码来源:AlfrescoPdfRendererContentTransformerWorker.java