Author: seanfinan
Date: Mon Jul 25 15:37:14 2022
New Revision: 1903012

URL: http://svn.apache.org/viewvc?rev=1903012&view=rev
Log:
Check for missing directory or command

Modified:
    
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java

Modified: 
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java
URL: 
http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java?rev=1903012&r1=1903011&r2=1903012&view=diff
==============================================================================
--- 
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java
 (original)
+++ 
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java
 Mon Jul 25 15:37:14 2022
@@ -37,7 +37,7 @@ public class CommandRunner extends JCasA
    private String _cmd;
 
    static public final String CMD_DIR_PARAM = "CommandDir";
-   static public final String CMD_DIR_DESC = "Set a value for parameter 
Command's directory.";
+   static public final String CMD_DIR_DESC = "The Command Executable's 
directory.";
    @ConfigurationParameter(
          name = CMD_DIR_PARAM,
          description = CMD_DIR_DESC,
@@ -46,7 +46,7 @@ public class CommandRunner extends JCasA
    private String _cmdDir;
 
    static public final String DIR_PARAM = "Dir";
-   static public final String DIR_DESC = "Set a value for parameter Command's 
root directory.";
+   static public final String DIR_DESC = "The Command's root directory.";
    @ConfigurationParameter(
          name = DIR_PARAM,
          description = DIR_DESC,
@@ -85,7 +85,7 @@ public class CommandRunner extends JCasA
    private String _wait;
 
    static public final String LOG_NAME_PARAM = "Log";
-   static public final String LOG_NAME_DESC = "Set a name for the CTAKES 
logger.  Default is the Command.";
+   static public final String LOG_NAME_DESC = "A name for the streaming 
logger.  Default is the Command.";
    @ConfigurationParameter(
          name = LOG_NAME_PARAM,
          description = LOG_NAME_DESC,
@@ -110,6 +110,16 @@ public class CommandRunner extends JCasA
    @Override
    public void initialize( final UimaContext context ) throws 
ResourceInitializationException {
       super.initialize( context );
+      if ( _cmdDir != null && !_cmdDir.isEmpty() && !( new File( _cmdDir 
).exists() ) ) {
+         LOGGER.warn( "Cannot find Command Directory " + _cmdDir );
+      }
+      if ( _dir != null && !_dir.isEmpty() && !( new File( _dir ).exists() ) ) 
{
+         LOGGER.warn( "Cannot find Directory " + _dir );
+      }
+      final String command = ( _cmdDir == null || _cmdDir.isEmpty() ) ? _cmd : 
_cmdDir + File.separator + _cmd;
+      if ( !( new File( command ).exists() ) ) {
+         LOGGER.warn( "Cannot find Command " + command );
+      }
       if ( _perDoc.equalsIgnoreCase( "yes" ) || _perDoc.equalsIgnoreCase( 
"true" ) ) {
          return;
       }
@@ -137,7 +147,7 @@ public class CommandRunner extends JCasA
 
 
    private void runCommand() throws IOException {
-      final String command = _cmdDir.isEmpty() ? _cmd : _cmdDir + 
File.separator + _cmd;
+      final String command = ( _cmdDir == null || _cmdDir.isEmpty() ) ? _cmd : 
_cmdDir + File.separator + _cmd;
       final SystemUtil.CommandRunner runner = new SystemUtil.CommandRunner( 
command );
       if ( _logFile != null && !_logFile.isEmpty() ) {
          runner.setLogFiles( _logFile, _logFile );


Reply via email to