mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fixed AR-435: Added system bootstrap and shutdown hooks for native executables
- See the RuntimeExecBeansTest-context.xml for examples of how to put these together - Shutdown hooks are executed on ApplicationContext shutdown or VM shutdown, whichever is first Moved native executable error code detection into RuntimeExec class - This affects any existing RuntimeExecContentTransformers (e.g. TidyTransformer) Made OS search use regular expressions - Command search order is: Exact name, First matching REGEX, * - Note that * is a special case for 'default'. The REGEX equivalent is .* git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2448 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -211,7 +211,7 @@
|
||||
<entry key="Linux">
|
||||
<value>imconvert ${source} ${options} ${target}</value>
|
||||
</entry>
|
||||
<entry key="*">
|
||||
<entry key=".*">
|
||||
<value>imconvert "${source}" ${options} "${target}"</value>
|
||||
</entry>
|
||||
</map>
|
||||
|
@@ -1,3 +1,4 @@
|
||||
# Content-related messages
|
||||
|
||||
content.content_missing=The node''s content is missing: \n node: {0} \n reader: {1} \n Please contact your system administrator.
|
||||
content.runtime_exec.property_moved=The property ''errorCodes'' has moved down onto the RuntimeExec class
|
@@ -18,10 +18,7 @@ package org.alfresco.repo.content.transform;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
@@ -69,13 +66,9 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
||||
private MimetypeService mimetypeService;
|
||||
private RuntimeExec checkCommand;
|
||||
private RuntimeExec transformCommand;
|
||||
private Set<Integer> errCodes;
|
||||
|
||||
public RuntimeExecutableContentTransformer()
|
||||
{
|
||||
this.errCodes = new HashSet<Integer>(2);
|
||||
errCodes.add(1);
|
||||
errCodes.add(2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,32 +111,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
||||
*/
|
||||
public void setErrorCodes(String errCodesStr)
|
||||
{
|
||||
StringTokenizer tokenizer = new StringTokenizer(errCodesStr, " ,");
|
||||
while(tokenizer.hasMoreElements())
|
||||
{
|
||||
String errCodeStr = tokenizer.nextToken();
|
||||
// attempt to convert it to an integer
|
||||
try
|
||||
{
|
||||
int errCode = Integer.parseInt(errCodeStr);
|
||||
this.errCodes.add(errCode);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Error codes string must be integers: " + errCodesStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param exitValue the command exit value
|
||||
* @return Returns true if the code is a listed failure code
|
||||
*
|
||||
* @see #setErrorCodes(String)
|
||||
*/
|
||||
private boolean isFailureCode(int exitValue)
|
||||
{
|
||||
return errCodes.contains((Integer)exitValue);
|
||||
throw new AlfrescoRuntimeException("content.runtime_exec.property_moved");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +135,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
||||
{
|
||||
ExecutionResult result = checkCommand.execute();
|
||||
// check the return code
|
||||
available = !isFailureCode(result.getExitValue());
|
||||
available = result.getSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -263,7 +231,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
||||
}
|
||||
|
||||
// check
|
||||
if (isFailureCode(result.getExitValue()))
|
||||
if (!result.getSuccess())
|
||||
{
|
||||
throw new ContentIOException("Transformation failed - status indicates an error: \n" + result);
|
||||
}
|
||||
|
Reference in New Issue
Block a user