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:
Derek Hulley
2006-02-20 01:22:32 +00:00
parent ac19d98707
commit 58d6778173
3 changed files with 5 additions and 36 deletions

View File

@@ -211,7 +211,7 @@
<entry key="Linux"> <entry key="Linux">
<value>imconvert ${source} ${options} ${target}</value> <value>imconvert ${source} ${options} ${target}</value>
</entry> </entry>
<entry key="*"> <entry key=".*">
<value>imconvert "${source}" ${options} "${target}"</value> <value>imconvert "${source}" ${options} "${target}"</value>
</entry> </entry>
</map> </map>

View File

@@ -1,3 +1,4 @@
# Content-related messages # 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.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

View File

@@ -18,10 +18,7 @@ package org.alfresco.repo.content.transform;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.ContentIOException;
@@ -69,13 +66,9 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
private MimetypeService mimetypeService; private MimetypeService mimetypeService;
private RuntimeExec checkCommand; private RuntimeExec checkCommand;
private RuntimeExec transformCommand; private RuntimeExec transformCommand;
private Set<Integer> errCodes;
public RuntimeExecutableContentTransformer() 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) public void setErrorCodes(String errCodesStr)
{ {
StringTokenizer tokenizer = new StringTokenizer(errCodesStr, " ,"); throw new AlfrescoRuntimeException("content.runtime_exec.property_moved");
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);
} }
/** /**
@@ -167,7 +135,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
{ {
ExecutionResult result = checkCommand.execute(); ExecutionResult result = checkCommand.execute();
// check the return code // check the return code
available = !isFailureCode(result.getExitValue()); available = result.getSuccess();
} }
else else
{ {
@@ -263,7 +231,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
} }
// check // check
if (isFailureCode(result.getExitValue())) if (!result.getSuccess())
{ {
throw new ContentIOException("Transformation failed - status indicates an error: \n" + result); throw new ContentIOException("Transformation failed - status indicates an error: \n" + result);
} }