diff --git a/jhove-apps/pom.xml b/jhove-apps/pom.xml index 416d9ed1a..b3415abef 100644 --- a/jhove-apps/pom.xml +++ b/jhove-apps/pom.xml @@ -33,7 +33,7 @@ - Jhove + edu.harvard.hul.ois.jhove.Jhove diff --git a/jhove-apps/src/main/java/UserHome.java b/jhove-apps/src/main/java/UserHome.java deleted file mode 100644 index 406d01d53..000000000 --- a/jhove-apps/src/main/java/UserHome.java +++ /dev/null @@ -1,33 +0,0 @@ -/********************************************************************** - * UserHome - JSTOR/Harvard Object Validation Environment - * Copyright 2006 by the President and Fellows of Harvard College - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - **********************************************************************/ - - - -/** - * Determine the default value of the Java user.home property. - */ -public class UserHome -{ - public static void main (String [] args) - { - System.out.println ("Default user.home is \"" + - System.getProperty ("user.home") + "\""); - } -} diff --git a/jhove-apps/src/main/java/Jhove.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/Jhove.java similarity index 75% rename from jhove-apps/src/main/java/Jhove.java rename to jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/Jhove.java index 72b289d9e..fbb42ee40 100644 --- a/jhove-apps/src/main/java/Jhove.java +++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/Jhove.java @@ -1,3 +1,5 @@ +package edu.harvard.hul.ois.jhove; + /********************************************************************** * Jhove - JSTOR/Harvard Object Validation Environment * Copyright 2004-2007 by the President and Fellows of Harvard College @@ -30,15 +32,13 @@ import java.util.logging.Level; import java.util.logging.Logger; -public class Jhove -{ +public class Jhove { /** Application name. */ private static final String NAME = "Jhove"; /** Logger for this class. */ private static final Logger LOGGER = Logger.getLogger(Jhove.class.getCanonicalName()); - private Jhove() - { + private Jhove() { throw new AssertionError("Should never enter private constructor"); } @@ -47,12 +47,10 @@ private Jhove() private static final String NOT_FOUND = "' not found"; private static final String HANDLER = "Handler '"; - /** * MAIN ENTRY POINT. */ - public static void main(String [] args) - { + public static void main(String[] args) { // Make sure we have a satisfactory version of Java. String version = System.getProperty("java.vm.version"); if (version.compareTo("1.8.0") < 0) { @@ -69,9 +67,11 @@ public static void main(String [] args) String configFile = JhoveBase.getConfigFileFromProperties(); String saxClass = JhoveBase.getSaxClassFromProperties(); - /* Pre-parse the command line for -c and -x config options. + /* + * Pre-parse the command line for -c and -x config options. * With Windows, we have to deal with quote marks on our own. - * With Unix, the shell takes care of quotes for us. */ + * With Unix, the shell takes care of quotes for us. + */ boolean quoted = false; for (int i = 0; i < args.length; i++) { if (quoted) { @@ -79,56 +79,53 @@ public static void main(String [] args) if (args[i].charAt(len - 1) == '"') { quoted = false; } - } - else { + } else { if (C_CONFIG_OPTION.equals(args[i])) { if (i < args.length - 1) { configFile = args[++i]; } - } - else if (X_CONFIG_OPTION.equals(args[i])) { + } else if (X_CONFIG_OPTION.equals(args[i])) { if (i < args.length - 1) { saxClass = args[++i]; } - } - else if (args[i].charAt(0) == '"') { + } else if (args[i].charAt(0) == '"') { quoted = true; } } } // Initialize the JHOVE engine. - String encoding = null; - String tempDir = null; - int bufferSize = -1; - String moduleName = null; - String handlerName = null; + String encoding = null; + String tempDir = null; + int bufferSize = -1; + String moduleName = null; + String handlerName = null; String aboutHandler = null; - String logLevel = null; - String outputFile = null; - boolean checksum = false; - boolean showRaw = false; - boolean signature = false; - List list = new ArrayList<>(); + String logLevel = null; + String outputFile = null; + boolean checksum = false; + boolean showRaw = false; + boolean signature = false; + List list = new ArrayList<>(); /* * Parse command line arguments: - * -m module Module name - * -h handler Output handler - * -e encoding Output encoding - * -H handler About handler - * -o output Output file pathname - * -t tempdir Directory for temp files - * -b bufsize Buffer size for buffered I/O - * -k Calculate checksums - * -r Display raw numeric flags - * -s Check internal signatures only - * dirFileOrUri Directories, file pathnames, or URIs + * -m module Module name + * -h handler Output handler + * -e encoding Output encoding + * -H handler About handler + * -o output Output file pathname + * -t tempdir Directory for temp files + * -b bufsize Buffer size for buffered I/O + * -k Calculate checksums + * -r Display raw numeric flags + * -s Check internal signatures only + * dirFileOrUri Directories, file pathnames, or URIs * * The following arguments were defined in previous * versions, but are now obsolete - * -p param OBSOLETE - * -P param OBSOLETE + * -p param OBSOLETE + * -P param OBSOLETE */ quoted = false; @@ -142,93 +139,74 @@ else if (args[i].charAt(0) == '"') { filename.append(args[i].substring(0, len - 1)); list.add(filename.toString()); quoted = false; - } - else { + } else { filename.append(args[i]); } - } - else { + } else { if (C_CONFIG_OPTION.equals(args[i])) { i++; - } - else if ("-m".equals(args[i])) { + } else if ("-m".equals(args[i])) { if (i < args.length - 1) { moduleName = args[++i]; } - } - else if ("-p".equals(args[i])) { + } else if ("-p".equals(args[i])) { // Obsolete -- but eat the next arg for compatibility if (i < args.length - 1) { @SuppressWarnings("unused") String moduleParam = args[++i]; } - } - else if ("-h".equals(args[i])) { + } else if ("-h".equals(args[i])) { if (i < args.length - 1) { handlerName = args[++i]; } - } - else if ("-P".equals(args[i])) { + } else if ("-P".equals(args[i])) { // Obsolete -- but eat the next arg for compatibility if (i < args.length - 1) { @SuppressWarnings("unused") String handlerParam = args[++i]; } - } - else if ("-e".equals(args[i])) { + } else if ("-e".equals(args[i])) { if (i < args.length - 1) { encoding = args[++i]; } - } - else if ("-H".equals(args[i])) { + } else if ("-H".equals(args[i])) { if (i < args.length - 1) { aboutHandler = args[++i]; } - } - else if ("-l".equals(args[i])) { + } else if ("-l".equals(args[i])) { if (i < args.length - 1) { logLevel = args[++i]; } - } - else if ("-o".equals(args[i])) { + } else if ("-o".equals(args[i])) { if (i < args.length - 1) { outputFile = args[++i]; } - } - else if (X_CONFIG_OPTION.equals(args[i])) { + } else if (X_CONFIG_OPTION.equals(args[i])) { i++; - } - else if ("-t".equals(args[i])) { + } else if ("-t".equals(args[i])) { if (i < args.length - 1) { tempDir = args[++i]; } - } - else if ("-b".equals(args[i])) { + } else if ("-b".equals(args[i])) { if (i < args.length - 1) { try { bufferSize = Integer.parseInt(args[++i]); - } - catch (NumberFormatException nfe) { + } catch (NumberFormatException nfe) { LOGGER.log(Level.WARNING, "Invalid buffer size, using default."); } } - } - else if ("-k".equals(args[i])) { + } else if ("-k".equals(args[i])) { checksum = true; - } - else if ("-r".equals(args[i])) { + } else if ("-r".equals(args[i])) { showRaw = true; - } - else if ("-s".equals(args[i])) { + } else if ("-s".equals(args[i])) { signature = true; - } - else if (args[i].charAt(0) != '-') { + } else if (args[i].charAt(0) != '-') { if (args[i].charAt(0) == '"') { filename = new StringBuilder(); filename.append(args[i].substring(1)); quoted = true; - } - else { + } else { list.add(args[i]); } } @@ -237,13 +215,13 @@ else if (args[i].charAt(0) != '-') { if (quoted) { list.add(filename.toString()); } - + JhoveBase je = new JhoveBase(); // Only set the log level if a param value was assigned if (logLevel != null) { je.setLogLevel(logLevel); } - je.init (configFile, saxClass); + je.init(configFile, saxClass); if (encoding == null) { encoding = je.getEncoding(); } @@ -285,8 +263,7 @@ else if (args[i].charAt(0) != '-') { je.setShowRawFlag(showRaw); je.setSignatureFlag(signature); je.dispatch(app, module, about, handler, outputFile, dirFileOrUri); - } - catch (Exception e) { + } catch (Exception e) { LOGGER.log(Level.SEVERE, e.getMessage()); e.printStackTrace(System.err); System.exit(ExitCode.ERROR.getReturnCode()); diff --git a/jhove-apps/src/main/java/JhoveView.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/JhoveView.java similarity index 90% rename from jhove-apps/src/main/java/JhoveView.java rename to jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/JhoveView.java index 1ead3f6ef..641034268 100644 --- a/jhove-apps/src/main/java/JhoveView.java +++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/JhoveView.java @@ -17,6 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA **********************************************************************/ +package edu.harvard.hul.ois.jhove.viewer; import edu.harvard.hul.ois.jhove.App; import edu.harvard.hul.ois.jhove.ExitCode; @@ -35,8 +36,7 @@ /** * JhoveView - JSTOR/Harvard Object Validation Environment. */ -public class JhoveView -{ +public class JhoveView { private static final Logger LOGGER = Logger.getLogger(JhoveView.class.getCanonicalName()); /** Application name. */ @@ -45,8 +45,7 @@ public class JhoveView private static final String ICON_PATH = "org/openpreservation/jhove/icon.png"; //$NON-NLS-1$ /** Stub constructor. */ - private JhoveView() - { + private JhoveView() { } /** @@ -54,8 +53,7 @@ private JhoveView() * * @param args Command-line arguments */ - public static void main(String[] args) - { + public static void main(String[] args) { // Make sure we have a satisfactory version of Java. String version = System.getProperty("java.vm.version"); //$NON-NLS-1$ if (version.compareTo("1.8.0") < 0) { //$NON-NLS-1$ @@ -83,19 +81,16 @@ public static void main(String[] args) if (args[i].charAt(len - 1) == '"') { quoted = false; } - } - else { + } else { if ("-c".equals(args[i])) { if (i < args.length - 1) { configFile = args[++i]; } - } - else if ("-x".equals(args[i])) { + } else if ("-x".equals(args[i])) { if (i < args.length - 1) { saxClass = args[++i]; } - } - else if (args[i].charAt(0) == '"') { + } else if (args[i].charAt(0) == '"') { quoted = true; } } @@ -105,21 +100,19 @@ else if (args[i].charAt(0) == '"') { JhoveBase je = new JhoveBase(); try { je.init(configFile, saxClass); - } - catch (JhoveException e) { + } catch (JhoveException e) { errorAlert(e.getMessage()); // Keep going, so user can correct in editor } // Create the main window to select a file. JhoveWindow jwin = new JhoveWindow(app, je); - URL url = ClassLoader.getSystemResource(ICON_PATH); //$NON-NLS-1$ + URL url = ClassLoader.getSystemResource(ICON_PATH); // $NON-NLS-1$ Toolkit kit = Toolkit.getDefaultToolkit(); jwin.setIconImage(kit.createImage(url)); - jwin.setVisible (true); + jwin.setVisible(true); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(System.err); LOGGER.log(Level.SEVERE, e.getMessage()); System.exit(ExitCode.ERROR.getReturnCode()); @@ -127,8 +120,7 @@ else if (args[i].charAt(0) == '"') { } /** Displays an error alert. */ - private static void errorAlert(String msg) - { + private static void errorAlert(String msg) { JFrame hiddenFrame = new JFrame(); // Truncate long messages so the alert isn't wider than the screen String message = (msg.length() > 80) ? msg.substring(0, 79) + "..." : msg; diff --git a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/gzip/package-info.java b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/gzip/package-info.java index 722738d5a..be0150ea1 100644 --- a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/gzip/package-info.java +++ b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/gzip/package-info.java @@ -10,4 +10,4 @@ *
  • JHOVE home page * */ -package hul.ois.jhove.module.gzip; +package edu.harvard.hul.ois.jhove.module.gzip; diff --git a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/package-info.java b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/package-info.java index c918dcb08..3bf6175b8 100644 --- a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/package-info.java +++ b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/package-info.java @@ -10,4 +10,4 @@ *
  • JHOVE home page * */ -package hul.ois.jhove.module.warc; +package edu.harvard.hul.ois.jhove.module.warc; diff --git a/jhove-installer/pom.xml b/jhove-installer/pom.xml index be0e88eee..6e9ab94a9 100644 --- a/jhove-installer/pom.xml +++ b/jhove-installer/pom.xml @@ -14,7 +14,7 @@ jhove-xplt-installer-${project.version}.jar - 5.0.10 + 5.1.3 ${project.build.directory}/staging ${project.build.directory} ${project.build.scriptSourceDirectory} @@ -121,6 +121,8 @@ ${izpack.version} UTF-8 + jhove-izpack-installer + ${project.version} diff --git a/jhove-installer/src/main/scripts/jhove b/jhove-installer/src/main/scripts/jhove index 072df785c..3ef25fc49 100644 --- a/jhove-installer/src/main/scripts/jhove +++ b/jhove-installer/src/main/scripts/jhove @@ -63,4 +63,4 @@ fi CONFIG="${JHOVE_HOME}/conf/jhove.conf" # Set class path and invoke Java -java -Xss1024k -classpath "${CP}" Jhove -c "${CONFIG}" "${@}" +java -Xss1024k -classpath "${CP}" edu.harvard.hul.ois.jhove.Jhove -c "${CONFIG}" "${@}" diff --git a/jhove-installer/src/main/scripts/jhove-gui b/jhove-installer/src/main/scripts/jhove-gui index dde48c872..46cff3ec5 100644 --- a/jhove-installer/src/main/scripts/jhove-gui +++ b/jhove-installer/src/main/scripts/jhove-gui @@ -63,4 +63,4 @@ fi CONFIG="${JHOVE_HOME}/conf/jhove.conf" # Set class path and invoke Java -java -Xss1024k -classpath "${CP}" JhoveView -c "${CONFIG}" "${@}" +java -Xss1024k -classpath "${CP}" edu.harvard.hul.ois.jhove.viewer.JhoveView -c "${CONFIG}" "${@}" diff --git a/jhove-installer/src/main/scripts/jhove-gui.bat b/jhove-installer/src/main/scripts/jhove-gui.bat index 29a05aad4..4c68b4e5b 100644 --- a/jhove-installer/src/main/scripts/jhove-gui.bat +++ b/jhove-installer/src/main/scripts/jhove-gui.bat @@ -47,4 +47,4 @@ REM Set default configuration location SET "CONFIG=%JHOVE_HOME%conf\jhove.conf" REM Set class path and invoke Java -java -Xss1024k -classpath "%CP%" JhoveView -c "%CONFIG%" %* +java -Xss1024k -classpath "%CP%" edu.harvard.hul.ois.jhove.viewer.JhoveView -c "%CONFIG%" %* diff --git a/jhove-installer/src/main/scripts/jhove.bat b/jhove-installer/src/main/scripts/jhove.bat index 54ac7e4c0..0e78b8dee 100644 --- a/jhove-installer/src/main/scripts/jhove.bat +++ b/jhove-installer/src/main/scripts/jhove.bat @@ -47,4 +47,4 @@ REM Set default configuration location SET "CONFIG=%JHOVE_HOME%conf\jhove.conf" REM Set class path and invoke Java -java -Xss1024k -classpath "%CP%" Jhove -c "%CONFIG%" %* +java -Xss1024k -classpath "%CP%" edu.harvard.hul.ois.jhove.Jhove -c "%CONFIG%" %* diff --git a/jhove-modules/xml-hul/src/main/java/edu/harvard/hul/ois/jhove/module/xml/XmlModuleHandler.java b/jhove-modules/xml-hul/src/main/java/edu/harvard/hul/ois/jhove/module/xml/XmlModuleHandler.java index 02788a70f..bb06ebb71 100644 --- a/jhove-modules/xml-hul/src/main/java/edu/harvard/hul/ois/jhove/module/xml/XmlModuleHandler.java +++ b/jhove-modules/xml-hul/src/main/java/edu/harvard/hul/ois/jhove/module/xml/XmlModuleHandler.java @@ -8,6 +8,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.text.MessageFormat; @@ -349,19 +350,9 @@ public InputSource resolveEntity(String publicId, String systemId) if (ent == null) { try { URL obj = new URL(systemId); - HttpURLConnection conn = (HttpURLConnection) obj - .openConnection(); - - int status = conn.getResponseCode(); - if (status == HttpURLConnection.HTTP_MOVED_TEMP - || status == HttpURLConnection.HTTP_MOVED_PERM - || status == HttpURLConnection.HTTP_SEE_OTHER) { - - String newUrl = conn.getHeaderField("Location"); - conn = (HttpURLConnection) new URL(newUrl).openConnection(); - ent = new InputSource(conn.getInputStream()); - } - + ent = new InputSource(obj.openStream()); + } catch (IOException e) { + return null; } catch (Exception e) { // Depending on the JDK version, super.resolveEntity // may or may not be formally capable of throwing an diff --git a/pom.xml b/pom.xml index 5cd8b192a..ce6f42974 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ 3.0.1 2.19.1 2.5.3 - 0.7.9 + 0.8.7 1.8 1.8 ${maven.build.timestamp}