Skip to content
Snippets Groups Projects
Commit da6e0d78 authored by brinn's avatar brinn
Browse files

Add method toStatus().

SVN: 24105
parent 567165bb
No related merge requests found
...@@ -26,6 +26,7 @@ import org.apache.log4j.Logger; ...@@ -26,6 +26,7 @@ import org.apache.log4j.Logger;
import ch.systemsx.cisd.base.utilities.OSUtilities; import ch.systemsx.cisd.base.utilities.OSUtilities;
import ch.systemsx.cisd.common.concurrent.ExecutionResult; import ch.systemsx.cisd.common.concurrent.ExecutionResult;
import ch.systemsx.cisd.common.concurrent.ExecutionStatus; import ch.systemsx.cisd.common.concurrent.ExecutionStatus;
import ch.systemsx.cisd.common.exceptions.Status;
/** /**
* Class that keeps around the result of running an Operating System process. * Class that keeps around the result of running an Operating System process.
...@@ -241,6 +242,34 @@ public final class ProcessResult ...@@ -241,6 +242,34 @@ public final class ProcessResult
return errorOutput; return errorOutput;
} }
/**
* Returns this result as a {@link Status}.
*/
public Status toStatus()
{
if (isOK())
{
return Status.OK;
} else
{
if (isTimedOut())
{
return Status.createRetriableError("Process timed out");
}
if (isInterruped())
{
return Status.createRetriableError("Process got interrupted");
}
if (StringUtils.isBlank(getStartupFailureMessage()) == false)
{
return Status.createError(getStartupFailureMessage());
}
return Status.createError("Exit Value: " + getExitValue() + "\n"
+ StringUtils.join(getErrorOutput(), "\n"));
}
}
/** /**
* Returns the text output of the process (<code>stdout</code> and <code>stderr</code>). If it * Returns the text output of the process (<code>stdout</code> and <code>stderr</code>). If it
* not available (see {@link #isOutputAvailable()}, an empty list is returned. * not available (see {@link #isOutputAvailable()}, an empty list is returned.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment