Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: v1.33.0-SNAPSHOT #984

Merged
merged 16 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# See https://docs.docker.com/engine/userguide/eng-image/multistage-build/
# First build the app on a maven open jdk 11 container
FROM maven:3-eclipse-temurin-11-focal as dev-builder
ARG JHOVE_VERSION=1.33.0-SNAPSHOT
FROM maven:3-eclipse-temurin-11-alpine AS dev-builder
ARG JHOVE_VERSION
ENV JHOVE_VERSION=${JHOVE_VERSION:-1.32.0-RC1}
ENV JHOVE_VERSION=${JHOVE_VERSION}

# Copy the current dev source branch to a local build dir
COPY . /build/jhove/
WORKDIR /build/jhove
RUN apk add --no-cache git
WORKDIR /build

# Clone the repo, checkout the revision and build the application
RUN git clone https://github.com/openpreserve/jhove.git

RUN mvn clean package && java -jar jhove-installer/target/jhove-xplt-installer-${JHOVE_VERSION}.jar docker-install.xml
WORKDIR /build/jhove
RUN git checkout v${JHOVE_VERSION} && mvn clean package && java -jar jhove-installer/target/jhove-xplt-installer-${JHOVE_VERSION}.jar docker-install.xml

# Now build a Java JRE for the Alpine application image
# https://github.com/docker-library/docs/blob/master/eclipse-temurin/README.md#creating-a-jre-using-jlink
FROM eclipse-temurin:11 as jre-builder
FROM eclipse-temurin:11-jdk-alpine AS jre-builder

# Create a custom Java runtime
RUN "$JAVA_HOME/bin/jlink" \
Expand All @@ -24,14 +28,14 @@ RUN "$JAVA_HOME/bin/jlink" \
--output /javaruntime

# Now the final application image
FROM debian:bullseye-slim
FROM alpine:3

# Set for additional arguments passed to the java run command, no default
ARG JAVA_OPTS
ENV JAVA_OPTS=$JAVA_OPTS
# Specify the veraPDF REST version if you want to (to be used in build automation)
ARG JHOVE_VERSION
ENV JHOVE_VERSION=${JHOVE_VERSION:-1.32.0-RC1}
ENV JHOVE_VERSION=${JHOVE_VERSION}

# Copy the JRE from the previous stage
ENV JAVA_HOME=/opt/java/openjdk
Expand All @@ -40,7 +44,7 @@ COPY --from=jre-builder /javaruntime $JAVA_HOME

# Since this is a running network service we'll create an unprivileged account
# which will be used to perform the rest of the work and run the actual service:
RUN useradd --system --user-group --home-dir=/opt/jhove jhove
RUN addgroup -S jhove && adduser -S -G jhove -h /opt/jhove jhove
RUN mkdir --parents /var/opt/jhove/logs && chown -R jhove:jhove /var/opt/jhove

USER jhove
Expand Down
53 changes: 53 additions & 0 deletions Dockerfile_dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# See https://docs.docker.com/engine/userguide/eng-image/multistage-build/
# First build the app on a maven open jdk 11 container
ARG JHOVE_VERSION=1.33.0-SNAPSHOT
FROM maven:3-eclipse-temurin-11-alpine AS dev-builder
ARG JHOVE_VERSION
ENV JHOVE_VERSION=${JHOVE_VERSION}

# Copy the current dev source branch to a local build dir
COPY . /build/jhove/
WORKDIR /build/jhove

RUN mvn clean package && java -jar jhove-installer/target/jhove-xplt-installer-${JHOVE_VERSION}.jar docker-install.xml

# Now build a Java JRE for the Alpine application image
# https://github.com/docker-library/docs/blob/master/eclipse-temurin/README.md#creating-a-jre-using-jlink
FROM eclipse-temurin:11-jdk-alpine AS jre-builder

# Create a custom Java runtime
RUN "$JAVA_HOME/bin/jlink" \
--add-modules java.base,java.logging,java.xml,jdk.crypto.ec \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

# Now the final application image
FROM alpine:3

# Set for additional arguments passed to the java run command, no default
ARG JAVA_OPTS
ENV JAVA_OPTS=$JAVA_OPTS
# Specify the veraPDF REST version if you want to (to be used in build automation)
ARG JHOVE_VERSION
ENV JHOVE_VERSION=${JHOVE_VERSION}

# Copy the JRE from the previous stage
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-builder /javaruntime $JAVA_HOME

# Since this is a running network service we'll create an unprivileged account
# which will be used to perform the rest of the work and run the actual service:
RUN addgroup -S jhove && adduser -S -G jhove -h /opt/jhove jhove
RUN mkdir --parents /var/opt/jhove/logs && chown -R jhove:jhove /var/opt/jhove

USER jhove

WORKDIR /opt/jhove
# Copy the application from the previous stage
COPY --from=dev-builder /opt/jhove/ /opt/jhove/

ENTRYPOINT ["/opt/jhove/jhove"]
55 changes: 55 additions & 0 deletions Dockerfile_installer
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# See https://docs.docker.com/engine/userguide/eng-image/multistage-build/
# First build the app on a maven open jdk 11 container
ARG JHOVE_VERSION=1.32
FROM eclipse-temurin:11-jdk-alpine AS app-installer
ARG JHOVE_VERSION
ENV JHOVE_VERSION=${JHOVE_VERSION}

WORKDIR /tmp
COPY docker-install.xml .
RUN wget -O /tmp/jhove-installer.jar https://software.openpreservation.org/releases/jhove/jhove-${JHOVE_VERSION}.jar
RUN java -jar jhove-installer.jar docker-install.xml

# Now build a Java JRE for the Alpine application image
# https://github.com/docker-library/docs/blob/master/eclipse-temurin/README.md#creating-a-jre-using-jlink
FROM eclipse-temurin:11-jdk-alpine AS jre-builder

# Create a custom Java runtime
RUN "$JAVA_HOME/bin/jlink" \
--add-modules java.base,java.logging,java.xml,jdk.crypto.ec \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

# Now the final application image
FROM alpine:3

# Set for additional arguments passed to the java run command, no default
ARG JAVA_OPTS
ENV JAVA_OPTS=$JAVA_OPTS
# Specify the veraPDF REST version if you want to (to be used in build automation)
ARG JHOVE_VERSION
ENV JHOVE_VERSION=${JHOVE_VERSION}

# Copy the JRE from the previous stage
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-builder /javaruntime $JAVA_HOME

# Since this is a running network service we'll create an unprivileged account
# which will be used to perform the rest of the work and run the actual service:
RUN addgroup -S jhove && adduser -S -G jhove -h /opt/jhove jhove
RUN mkdir --parents /var/opt/jhove/logs && chown -R jhove:jhove /var/opt/jhove

USER jhove
WORKDIR /opt/jhove

# Copy the application from the previous stage
COPY --from=app-installer /opt/jhove/ /opt/jhove/

WORKDIR /data
VOLUME [ "/data" ]

ENTRYPOINT ["/opt/jhove/jhove"]
33 changes: 15 additions & 18 deletions jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/Jhove.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package edu.harvard.hul.ois.jhove;

/**********************************************************************
* Jhove - JSTOR/Harvard Object Validation Environment
* Copyright 2004-2007 by the President and Fellows of Harvard College
Expand All @@ -19,13 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
**********************************************************************/

import edu.harvard.hul.ois.jhove.App;
import edu.harvard.hul.ois.jhove.ExitCode;
import edu.harvard.hul.ois.jhove.CoreMessageConstants;
import edu.harvard.hul.ois.jhove.JhoveBase;
import edu.harvard.hul.ois.jhove.Module;
import edu.harvard.hul.ois.jhove.OutputHandler;
package edu.harvard.hul.ois.jhove;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -38,14 +30,15 @@ public class Jhove {
/** Logger for this class. */
private static final Logger LOGGER = Logger.getLogger(Jhove.class.getCanonicalName());

private Jhove() {
throw new AssertionError("Should never enter private constructor");
}

private static final String C_CONFIG_OPTION = "-c";
private static final String X_CONFIG_OPTION = "-x";
private static final String NOT_FOUND = "' not found";
private static final String NOT_FOUND = "not found";
private static final String HANDLER = "Handler '";
private static final String MODULE = "Module";

private Jhove() {
throw new AssertionError("Should never enter private constructor");
}

/**
* MAIN ENTRY POINT.
Expand Down Expand Up @@ -233,17 +226,17 @@ public static void main(String[] args) {
}
Module module = je.getModule(moduleName);
if (module == null && moduleName != null) {
LOGGER.log(Level.SEVERE, "Module '" + moduleName + NOT_FOUND);
LOGGER.log(Level.SEVERE, notFoundMessage(MODULE, moduleName));
System.exit(ExitCode.ERROR.getReturnCode());
}
OutputHandler about = je.getHandler(aboutHandler);
if (about == null && aboutHandler != null) {
LOGGER.log(Level.SEVERE, HANDLER + aboutHandler + NOT_FOUND);
LOGGER.log(Level.SEVERE, notFoundMessage(HANDLER, aboutHandler));
System.exit(ExitCode.ERROR.getReturnCode());
}
OutputHandler handler = je.getHandler(handlerName);
if (handler == null && handlerName != null) {
LOGGER.log(Level.SEVERE, HANDLER + handlerName + NOT_FOUND);
LOGGER.log(Level.SEVERE, notFoundMessage(HANDLER, handlerName));
System.exit(ExitCode.ERROR.getReturnCode());
}
String[] dirFileOrUri = null;
Expand All @@ -264,9 +257,13 @@ public static void main(String[] args) {
je.setSignatureFlag(signature);
je.dispatch(app, module, about, handler, outputFile, dirFileOrUri);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage());
LOGGER.log(Level.SEVERE, e.getMessage(), e);
e.printStackTrace(System.err);
System.exit(ExitCode.ERROR.getReturnCode());
}
}

private static final String notFoundMessage(final String notFoundType, final String notFoundName) {
return String.format("%s '%s' %s", notFoundType, notFoundName, NOT_FOUND);
}
}
26 changes: 26 additions & 0 deletions jhove-bbt/scripts/create-1.33-target.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,29 @@ echo "TEST BASELINE: Creating baseline"
echo " - copying ${baselineRoot} baseline to ${targetRoot}"
cp -R "${baselineRoot}" "${targetRoot}"


# Update release details for PDF module
find "${targetRoot}" -type f -name "*.pdf.jhove.xml" -exec sed -i 's/<reportingModule release="1.12.7" date="2024-08-22">PDF-hul<\/reportingModule>/<reportingModule release="1.12.8" date="2025-01-24">PDF-hul<\/reportingModule>/' {} \;
find "${targetRoot}" -type f -name "audit.jhove.xml" -exec sed -i 's/<module release="1.12.7">PDF-hul<\/module>/<module release="1.12.8">PDF-hul<\/module>/' {} \;
find "${targetRoot}" -type f -name "audit-PDF-hul.jhove.xml" -exec sed -i 's/<release>1.12.7<\/release>/<release>1.12.8<\/release>/' {} \;
find "${targetRoot}" -type f -name "audit-PDF-hul.jhove.xml" -exec sed -i 's/2024-08-22/2025-01-24/' {} \;

# Fix the results affected by the improvements to date handling in the PDF module
sed -i 's/<message offset/<message subMessage="For date property: CreationDate, value: Tue Feb 03 16:19:57 2004" offset/' "${targetRoot}/examples/modules/PDF-hul/AA_Banner.pdf.jhove.xml"
if [[ -f "${candidateRoot}/errors/modules/PDF-hul/pdf-hul-9-govdocs-065694.pdf.jhove.xml" ]]; then
cp "${candidateRoot}/errors/modules/PDF-hul/pdf-hul-9-govdocs-065694.pdf.jhove.xml" "${targetRoot}/errors/modules/PDF-hul/pdf-hul-9-govdocs-065694.pdf.jhove.xml"
fi

# Insert new PDF-2.x signature nodes into the PDF audit XML files
find "${targetRoot}" -type f -name "audit-PDF-hul.jhove.xml" -exec sed -i 's/<\/signatures>/ <signature>\n <type>Magic number<\/type>\n <value>%PDF-2.<\/value>\n <offset>0x0<\/offset>\n <use>Mandatory<\/use>\n <\/signature>\n <\/signatures>/' {} \;

# Copy the two new version regression test files, where handling of PDF version declaration has been improved/changed
declare -a pdf_version_affected=("errors/modules/PDF-hul/pdf-hul-61-CERN-2005-009.pdf.jhove.xml"
"regression/modules/PDF-hul/PDF-HUL-137.pdf.jhove.xml"
"regression/modules/PDF-hul/PDF-HUL-137_fixed.pdf.jhove.xml")
for filename in "${pdf_version_affected[@]}"
do
if [[ -f "${candidateRoot}/${filename}" ]]; then
cp "${candidateRoot}/${filename}" "${targetRoot}/${filename}"
fi
done
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public static JhoveMessage getMessageInstance(final String id,
return getMessageInstance(id, message, EMPTY_MESSAGE);
}

/**
public static JhoveMessage getMessageInstance(final JhoveMessage message, final String subMessage) {
return getMessageInstance(message.getId(), message.getMessage(), subMessage);
}

/**
* Create a new JhoveMessage instance with the given id, message and
* sub-message
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ public void testMessageInstanceEmptyId() {

@Test
public void testMessageInstanceNullId() {
final String id = null;
assertThrows("IllegalArgument exception expected",
IllegalArgumentException.class,
() -> {
JhoveMessages.getMessageInstance(null, "MSG");
JhoveMessages.getMessageInstance(id, "MSG");
});
}

Expand Down
2 changes: 1 addition & 1 deletion jhove-installer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<html.hul.version>1.4.4</html.hul.version>
<jpeg2000.hul.version>1.4.4</jpeg2000.hul.version>
<jpeg.hul.version>1.5.4</jpeg.hul.version>
<pdf.hul.version>1.12.7</pdf.hul.version>
<pdf.hul.version>1.12.8</pdf.hul.version>
<tiff.hul.version>1.9.5</tiff.hul.version>
<utf8.hul.version>1.7.4</utf8.hul.version>
<wave.hul.version>1.8.3</wave.hul.version>
Expand Down
2 changes: 1 addition & 1 deletion jhove-modules/pdf-hul/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>1.33.0-SNAPSHOT</version>
</parent>
<artifactId>pdf-hul</artifactId>
<version>1.12.7</version>
<version>1.12.8</version>
<name>JHOVE PDF Module HUL</name>
<description>PDF module developed by Harvard University Library</description>
</project>
Loading
Loading