mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
fix stylecheck
This commit is contained in:
@@ -147,15 +147,13 @@ public class ScriptLauncher {
|
|||||||
DSpaceRunnable script) {
|
DSpaceRunnable script) {
|
||||||
try {
|
try {
|
||||||
StepResult result = script.initialize(args, dSpaceRunnableHandler, null);
|
StepResult result = script.initialize(args, dSpaceRunnableHandler, null);
|
||||||
|
|
||||||
if (StepResult.Continue.equals(result)) {
|
if (StepResult.Continue.equals(result)) {
|
||||||
// only run the script, if the normal initialize is successful
|
// only run the script, if the normal initialize is successful
|
||||||
script.run();
|
script.run();
|
||||||
} else {
|
} else {
|
||||||
// otherwise - for example the script is started with the help argument
|
// otherwise - for example the script is started with the help argument
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
return 0;
|
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
script.printHelp();
|
script.printHelp();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@@ -35,7 +35,7 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
|||||||
* The CommandLine object for the script that'll hold the information
|
* The CommandLine object for the script that'll hold the information
|
||||||
*/
|
*/
|
||||||
protected CommandLine commandLine;
|
protected CommandLine commandLine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimal CommandLine object for the script that'll hold help information
|
* The minimal CommandLine object for the script that'll hold help information
|
||||||
*/
|
*/
|
||||||
@@ -69,8 +69,8 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
|||||||
* @param args The arguments given to the script
|
* @param args The arguments given to the script
|
||||||
* @param dSpaceRunnableHandler The DSpaceRunnableHandler object that defines from where the script was ran
|
* @param dSpaceRunnableHandler The DSpaceRunnableHandler object that defines from where the script was ran
|
||||||
* @param currentUser
|
* @param currentUser
|
||||||
* @return the result of this step; StepResult.Continue: continue the normal process, initialize is successful;
|
* @return the result of this step; StepResult.Continue: continue the normal process,
|
||||||
* otherwise exit the process (the help or version is shown)
|
* initialize is successful; otherwise exit the process (the help or version is shown)
|
||||||
* @throws ParseException If something goes wrong
|
* @throws ParseException If something goes wrong
|
||||||
*/
|
*/
|
||||||
public StepResult initialize(String[] args, DSpaceRunnableHandler dSpaceRunnableHandler,
|
public StepResult initialize(String[] args, DSpaceRunnableHandler dSpaceRunnableHandler,
|
||||||
@@ -79,35 +79,38 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
|||||||
this.setEpersonIdentifier(currentUser.getID());
|
this.setEpersonIdentifier(currentUser.getID());
|
||||||
}
|
}
|
||||||
this.setHandler(dSpaceRunnableHandler);
|
this.setHandler(dSpaceRunnableHandler);
|
||||||
|
|
||||||
// parse the command line in a first step for the help options
|
// parse the command line in a first step for the help options
|
||||||
// --> no other option is required
|
// --> no other option is required
|
||||||
StepResult result = this.parseForHelp(args);
|
StepResult result = this.parseForHelp(args);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case Exit:
|
case Exit:
|
||||||
// arguments of the command line matches the help options, handle this
|
// arguments of the command line matches the help options, handle this
|
||||||
handleHelpCommandLine();
|
handleHelpCommandLine();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Continue:
|
case Continue:
|
||||||
// arguments of the command line matches NOT the help options, parse the args for the normal options
|
// arguments of the command line matches NOT the help options, parse the args for the normal options
|
||||||
result = this.parse(args);
|
result = this.parse(args);
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** This method handle the help command line. In this easy implementation only the help is printed.
|
/**
|
||||||
* For more complexity override this method.
|
* This method handle the help command line. In this easy implementation only the help is printed. For more
|
||||||
*/
|
* complexity override this method.
|
||||||
private void handleHelpCommandLine() {
|
*/
|
||||||
printHelp();
|
private void handleHelpCommandLine() {
|
||||||
}
|
printHelp();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will take the primitive array of String objects that represent the parameters given to the String
|
* This method will take the primitive array of String objects that represent the parameters given to the String
|
||||||
* and it'll parse these into a CommandLine object that can be used by the script to retrieve the data
|
* and it'll parse these into a CommandLine object that can be used by the script to retrieve the data
|
||||||
* @param args The primitive array of Strings representing the parameters
|
* @param args The primitive array of Strings representing the parameters
|
||||||
@@ -118,15 +121,15 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
|||||||
setup();
|
setup();
|
||||||
return StepResult.Continue;
|
return StepResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StepResult parseForHelp(String[] args) throws ParseException {
|
private StepResult parseForHelp(String[] args) throws ParseException {
|
||||||
helpCommandLine = new DefaultParser().parse(getScriptConfiguration().getHelpOptions(), args);
|
helpCommandLine = new DefaultParser().parse(getScriptConfiguration().getHelpOptions(), args);
|
||||||
if (helpCommandLine.getOptions() != null && helpCommandLine.getOptions().length > 0) {
|
if (helpCommandLine.getOptions() != null && helpCommandLine.getOptions().length > 0) {
|
||||||
return StepResult.Exit;
|
return StepResult.Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return StepResult.Continue;
|
return StepResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method has to be included in every script and handles the setup of the script by parsing the CommandLine
|
* This method has to be included in every script and handles the setup of the script by parsing the CommandLine
|
||||||
@@ -200,9 +203,8 @@ public abstract class DSpaceRunnable<T extends ScriptConfiguration> implements R
|
|||||||
public void setEpersonIdentifier(UUID epersonIdentifier) {
|
public void setEpersonIdentifier(UUID epersonIdentifier) {
|
||||||
this.epersonIdentifier = epersonIdentifier;
|
this.epersonIdentifier = epersonIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum StepResult {
|
public enum StepResult {
|
||||||
Continue,
|
Continue, Exit;
|
||||||
Exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -105,17 +105,16 @@ public abstract class ScriptConfiguration<T extends DSpaceRunnable> implements B
|
|||||||
* @return the options value of this ScriptConfiguration
|
* @return the options value of this ScriptConfiguration
|
||||||
*/
|
*/
|
||||||
public abstract Options getOptions();
|
public abstract Options getOptions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The getter for the options of the Script (help informations)
|
* The getter for the options of the Script (help informations)
|
||||||
|
*
|
||||||
* @return the options value of this ScriptConfiguration for help
|
* @return the options value of this ScriptConfiguration for help
|
||||||
*/
|
*/
|
||||||
public Options getHelpOptions() {
|
public Options getHelpOptions() {
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
options.addOption(Option.builder("h").longOpt("help")
|
options.addOption(Option.builder("h").longOpt("help").desc("help").hasArg(false).required(false).build());
|
||||||
.desc("help")
|
|
||||||
.hasArg(false).required(false).build());
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
@@ -99,9 +99,9 @@ public class MetadataExportIT
|
|||||||
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
||||||
}
|
}
|
||||||
if (script != null) {
|
if (script != null) {
|
||||||
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
||||||
script.run();
|
script.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,9 +207,9 @@ public class MetadataExportIT
|
|||||||
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
||||||
}
|
}
|
||||||
if (script != null) {
|
if (script != null) {
|
||||||
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
||||||
script.run();
|
script.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Exception exceptionDuringTestRun = testDSpaceRunnableHandler.getException();
|
Exception exceptionDuringTestRun = testDSpaceRunnableHandler.getException();
|
||||||
@@ -237,9 +237,9 @@ public class MetadataExportIT
|
|||||||
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
||||||
}
|
}
|
||||||
if (script != null) {
|
if (script != null) {
|
||||||
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
||||||
script.run();
|
script.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Exception exceptionDuringTestRun = testDSpaceRunnableHandler.getException();
|
Exception exceptionDuringTestRun = testDSpaceRunnableHandler.getException();
|
||||||
|
@@ -144,9 +144,9 @@ public class MetadataImportIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
||||||
}
|
}
|
||||||
if (script != null) {
|
if (script != null) {
|
||||||
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
||||||
script.run();
|
script.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -702,9 +702,10 @@ public class CSVMetadataImportReferenceIT extends AbstractIntegrationTestWithDat
|
|||||||
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
||||||
}
|
}
|
||||||
if (script != null) {
|
if (script != null) {
|
||||||
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
if (DSpaceRunnable.StepResult.Continue
|
||||||
script.run();
|
.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
||||||
}
|
script.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (testDSpaceRunnableHandler.getException() != null) {
|
if (testDSpaceRunnableHandler.getException() != null) {
|
||||||
throw testDSpaceRunnableHandler.getException();
|
throw testDSpaceRunnableHandler.getException();
|
||||||
|
@@ -43,9 +43,9 @@ public class CurationIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
||||||
}
|
}
|
||||||
if (script != null) {
|
if (script != null) {
|
||||||
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
||||||
script.run();
|
script.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,9 +70,9 @@ public class CurationIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
||||||
}
|
}
|
||||||
if (script != null) {
|
if (script != null) {
|
||||||
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
if (DSpaceRunnable.StepResult.Continue.equals(script.initialize(args, testDSpaceRunnableHandler, null))) {
|
||||||
script.run();
|
script.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user