forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matus Kasak
committed
Dec 19, 2024
1 parent
b1f0978
commit abc6c39
Showing
24 changed files
with
9,938 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
dspace-api/src/main/java/org/dspace/health/additionalUtilities/IOUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.health.additionalUtilities; | ||
|
||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.InputStreamReader; | ||
|
||
public class IOUtils { | ||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(IOUtils.class); | ||
|
||
public static String runScript(File where, String[] cmd) { | ||
String message = null; | ||
try { | ||
ProcessBuilder pb = new ProcessBuilder(cmd); | ||
pb.directory( where ); | ||
Process p = pb.start(); | ||
BufferedReader std_out = new BufferedReader(new InputStreamReader(p.getInputStream()) ); | ||
BufferedReader std_err = new BufferedReader(new InputStreamReader(p.getErrorStream()) ); | ||
|
||
String s = null; | ||
message = "Returned stdout:\n"; | ||
while ((s = std_out.readLine()) != null) { | ||
message += s + "\n "; | ||
} | ||
message += "Returned stderr:\n"; | ||
while ((s = std_err.readLine()) != null) { | ||
message += s + "\n "; | ||
} | ||
|
||
//Wait to get exit value | ||
int exitValue = p.waitFor(); | ||
message += "Exit code: [" + String.valueOf( exitValue ) + "]\n"; | ||
|
||
} catch (Exception e) { | ||
message += "\nException:" + e.toString(); | ||
log.error( e ); | ||
} | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.