#!/usr/bin/qsh
# // THIS PRODUCT CONTAINS RESTRICTED MATERIALS OF IBM
# // 5724-I63, 5724-H88, 5655-N01, 5733-W61 (C) COPYRIGHT International Business Machines Corp., 1997, 2011
# // All Rights Reserved * Licensed Materials - Property of IBM
# // US Government Users Restricted Rights - Use, duplication or disclosure
# // restricted by GSA ADP Schedule Contract with IBM Corp.
#
# //  DESCRIPTION:
# //      Script file used to deploy ejb jar files into deployed jar files.

WAS_OS400_FILE_CREATE_AUTH="*RX"
WAS_OS400_DIR_CREATE_AUTH="*RX"

USE_HIGHEST_AVAILABLE_SDK=true
. $(/usr/bin/dirname $0)/setupCmdLine

if [ -e "$ITP_LOC/ejbdeploy" ] ; then

    BOOTPATH=${ITP_LOC}/batchboot.jar:${WAS_INSTALL_ROOT}/java/ext/iwsorbutil.jar

    CP=${ITP_LOC}/batch2.jar:${ITP_LOC}/batch2_nl1.jar

    WAS_EXT_DIRS=${WAS_INSTALL_ROOT}/plugins/j2ee.javax:${WAS_INSTALL_ROOT}/plugins/com.ibm.ws.runtime.eclipse:${WAS_INSTALL_ROOT}/plugins:${WAS_INSTALL_ROOT}/plugins/com.ibm.ws.runtime:${WAS_INSTALL_ROOT}/lib/j2ee.jar:${WAS_INSTALL_ROOT}/plugins:${WAS_EXT_DIRS}

    ${JAVA_HOME}/bin/java ${JAVA_FLAGS} \
      -Xbootclasspath/a:${BOOTPATH} \
      -Dwebsphere.lib.dir=${WAS_INSTALL_ROOT}/lib \
      -Ditp.loc=${ITP_LOC} \
      -Dorg.osgi.framework.bootdelegation=* \
      -Dejbdeploy.user.install.root=${USER_INSTALL_ROOT}/ejbdeploy \
      -Duser.install.root=${USER_INSTALL_ROOT} \
      -Dcom.ibm.sse.model.structuredbuilder="off" \
      -classpath ${CP} \
      -Dws.ext.dirs=${WAS_EXT_DIRS} \
      -Dos400.security.properties=${SECURITY_CFG} \
      com.ibm.etools.ejbdeploy.EJBDeploy "$@"

    RETCODE=$?

    # Ensure QEJBSVR all access to deploytool's itp/configuration directory if it exists
    if [ -d ${WAS_INSTALL_ROOT}/deploytool/itp/configuration ]; then
      chown -R QEJBSVR ${WAS_INSTALL_ROOT}/deploytool/itp/configuration 2> /dev/null
    fi
    # Ensure QEJBSVR all access to ejbdeploy.user.install.root location
    if [ -d ${USER_INSTALL_ROOT}/ejbdeploy ]; then
      chown -R QEJBSVR ${USER_INSTALL_ROOT}/ejbdeploy 2> /dev/null
    fi

    exit $RETCODE

else
   ${JAVA_HOME}/bin/java ${JAVA_FLAGS} -cp "${WAS_HOME}/lib/commandlineutils.jar" com.ibm.ws.install.commandline.utils.CommandLineUtils -ejbdeployfeaturenotinstalled  
fi
