diff --git a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardDownloadDBLib.java b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardDownloadDBLib.java index 85f5bbfcde..ea45e46e09 100644 --- a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardDownloadDBLib.java +++ b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardDownloadDBLib.java @@ -48,37 +48,45 @@ private MIRWizardDownloadDBLib(String name) { @Override public void doExecute() { - Element library = getInputXML().getChild("database").getChild("library"); + try { - if (library != null && library.getChildren().size() > 0) { - String libDir = MCRConfigurationDir.getConfigurationDirectory().getAbsolutePath() + File.separator + "lib"; + Element library = getInputXML().getChild("database").getChild("library"); - boolean success = true; - for (Element lib : library.getChildren()) { - String url = lib.getTextTrim(); - String fname = FilenameUtils.getName(url); - File file = new File(libDir + File.separator + fname); - try { + if (library != null && library.getChildren().size() > 0) { + String libDir = MCRConfigurationDir.getConfigurationDirectory().getAbsolutePath() + File.separator + + "lib"; - FileUtils.copyURLToFile(new URL(url), file); - MCRConfigurationDirSetup.loadExternalLibs(); + boolean success = true; + for (Element lib : library.getChildren()) { + String url = lib.getTextTrim(); + String fname = FilenameUtils.getName(url); + File file = new File(libDir + File.separator + fname); + try { - success = true; - } catch (Exception ex) { - LOGGER.error("Exception while downloading or loading database library: " + file.getAbsolutePath(), - ex); - success = false; - } + FileUtils.copyURLToFile(new URL(url), file); + MCRConfigurationDirSetup.loadExternalLibs(); + + success = true; + } catch (Exception ex) { + LOGGER.error("Exception while downloading or loading database library: " + + file.getAbsolutePath(), ex); + success = false; + } - if (success) { - this.result.setAttribute("lib", fname); - this.result.setAttribute("url", url); - this.result.setAttribute("to", libDir); - break; + if (success) { + this.result.setAttribute("lib", fname); + this.result.setAttribute("url", url); + this.result.setAttribute("to", libDir); + break; + } } - } - this.result.setSuccess(success); + this.result.setSuccess(success); + } + } catch (Exception ex) { + LOGGER.error("Exception while downloading DB library.", ex); + this.result.setResult(ex.toString()); + this.result.setSuccess(false); } } } diff --git a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardGenerateJPAConfig.java b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardGenerateJPAConfig.java index b73860e9cb..d610d7acd3 100644 --- a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardGenerateJPAConfig.java +++ b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardGenerateJPAConfig.java @@ -35,6 +35,7 @@ import org.mycore.mir.wizard.MIRWizardCommand; public class MIRWizardGenerateJPAConfig extends MIRWizardCommand { + private static final Logger LOGGER = LogManager.getLogger(); public MIRWizardGenerateJPAConfig() { diff --git a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardGenerateProperties.java b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardGenerateProperties.java index e40e628c35..689ea2f404 100644 --- a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardGenerateProperties.java +++ b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardGenerateProperties.java @@ -28,12 +28,17 @@ import java.util.Properties; import java.util.Scanner; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jdom2.Element; import org.mycore.common.config.MCRConfiguration2; import org.mycore.common.config.MCRConfigurationDir; import org.mycore.mir.wizard.MIRWizardCommand; public class MIRWizardGenerateProperties extends MIRWizardCommand { + + private static final Logger LOGGER = LogManager.getLogger(); + public MIRWizardGenerateProperties() { this("mycore.properties"); } @@ -67,9 +72,9 @@ public void doExecute() { scanner.close(); this.result.setSuccess(true); - } catch (Exception e) { - this.result.setResult(e.getMessage()); - + } catch (Exception ex) { + LOGGER.error("Exception while generating properties.", ex); + this.result.setResult(ex.toString()); this.result.setSuccess(false); } } diff --git a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardInitDatabase.java b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardInitDatabase.java index eca7aead08..67f2b7a7ea 100644 --- a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardInitDatabase.java +++ b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardInitDatabase.java @@ -43,10 +43,10 @@ public class MIRWizardInitDatabase extends MIRWizardCommand { - private final static String ACTION = "create"; - private static final Logger LOGGER = LogManager.getLogger(); + private final static String ACTION = "create"; + public MIRWizardInitDatabase() { this("init.database"); } @@ -79,8 +79,8 @@ public void doExecute() { this.result.setResult(res.toString()); } catch (IOException | PersistenceException ex) { LOGGER.error("Exception while initializing database.", ex); + this.result.setResult(ex.toString()); this.result.setSuccess(false); - this.result.setResult(ex.getMessage()); } } diff --git a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardInitSuperuser.java b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardInitSuperuser.java index 7050784a45..e401567265 100644 --- a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardInitSuperuser.java +++ b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardInitSuperuser.java @@ -24,6 +24,8 @@ import java.util.List; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.mycore.backend.jpa.MCREntityManagerProvider; import org.mycore.mir.wizard.MIRWizardCommand; import org.mycore.user2.MCRUserCommands; @@ -33,6 +35,8 @@ public class MIRWizardInitSuperuser extends MIRWizardCommand { + private static final Logger LOGGER = LogManager.getLogger(); + public MIRWizardInitSuperuser() { this("init.superuser"); } @@ -60,7 +64,9 @@ public void doExecute() { } } catch (Exception ex) { - this.result.setResult(ex.getMessage()); + LOGGER.error("Exception while initializing superuser.", ex); + this.result.setResult(ex.toString()); + this.result.setSuccess(false); } } } diff --git a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardLoadClassifications.java b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardLoadClassifications.java index 6d3f6f60e8..27f167c1e2 100644 --- a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardLoadClassifications.java +++ b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardLoadClassifications.java @@ -109,6 +109,7 @@ public void doExecute() { this.result.setResult(result); this.result.setSuccess(true); } catch (Exception ex) { + LOGGER.error("Exception while loading classifiactions.", ex); this.result.setResult(ex.toString()); this.result.setSuccess(false); } diff --git a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardSolr.java b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardSolr.java index e6f1d4c4a4..87b6c8f3b7 100644 --- a/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardSolr.java +++ b/mir-wizard/src/main/java/org/mycore/mir/wizard/command/MIRWizardSolr.java @@ -22,6 +22,8 @@ */ package org.mycore.mir.wizard.command; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.mycore.mir.wizard.MIRWizardCommand; import org.mycore.solr.commands.MCRSolrCommands; @@ -31,9 +33,12 @@ */ public class MIRWizardSolr extends MIRWizardCommand { - private static String DEFAULT_CORE = "main"; + private static final Logger LOGGER = LogManager.getLogger(); - private static String DEFAULT_CLASSIFICATION = "classification"; + + private static final String DEFAULT_CORE = "main"; + + private static final String DEFAULT_CLASSIFICATION = "classification"; public MIRWizardSolr() { this("solr"); @@ -57,7 +62,9 @@ public void doExecute() { this.result.setSuccess(true); } catch (final Exception ex) { - this.result.setResult(ex.getMessage()); + LOGGER.error("Exception while initializing SOLR.", ex); + this.result.setResult(ex.toString()); + this.result.setSuccess(false); } } }