#!/bin/sh
#
# Copyright 2010-2014, by the California Institute of Technology.
# ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged.
# Any commercial use must be negotiated with the Office of Technology Transfer
# at the California Institute of Technology.
#
# This software is subject to U. S. export control laws and regulations
# (22 C.F.R. 120-130 and 15 C.F.R. 730-774). To the extent that the software
# is subject to U.S. export control laws and regulations, the recipient has
# the responsibility to obtain export licenses or other export authority as
# may be required before exporting such information to foreign countries or
# providing access to foreign nationals.
#
# $Id: Validate 5853 2010-02-06 22:54:00Z shardman $

# Bourne Shell script that allows easy execution of the Validate Tool
# without the need to set the CLASSPATH or having to type in that
# long java command (java gov.nasa.pds.validate.ValidateLauncher ...)

# Expects the Validate Tool jar file to be in the ../lib directory.

# Check if the JAVA_HOME environment variable is set.
if [ -z "${JAVA_HOME}" ]; then
   echo "The JAVA_HOME environment variable is not set." 1>&2
   exit 1
fi

# Setup environment variables.
SCRIPT_DIR=`dirname $0`
PARENT_DIR=`cd ${SCRIPT_DIR}/.. && pwd`
LIB_DIR=${PARENT_DIR}/lib

# Check for dependencies.
if [ ! -f ${LIB_DIR}/validate-*.jar ]; then
    echo "Cannot find Validate Tool jar file in ${LIB_DIR}" 1>&2
    exit 1
fi

# Finds the jar file in LIB_DIR and sets it to VALIDATE_JAR.
VALIDATE_JAR=`ls ${LIB_DIR}/validate-*.jar`

# Executes Validate Tool via the executable jar file
# Arguments are passed in to the tool via '$@'
"${JAVA_HOME}"/bin/java -Xms1024m -Xmx2048m -jar ${VALIDATE_JAR} "$@"
