#!/bin/sh

# Licensed Materials - Property of IBM
# IBM Cognos Products: XQE
# (C) Copyright IBM Corp. 2010, 2021
# US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

# This batch file assumes it is being executed from bin or bin64 directory.
# update the paths to run from a different location.

# RolapSecurityTool - A tool to import and export security settings for ROLAP cube.
# Usage:
#         Options:
#                 -ds : Rolap datasource name
#                 -i : Importing cube security by specifying an input file name.
#                 -e : Exporting cube security by specifying an output file name.
#                 -u : username [optional]
#                 -p : password [optional]
#                 -n : namespace [optional]
#                 -dp : Dispatcher url, default is http://localhost:9300/p2pd/servlet/dispatch [optional]
#                 -params : Specifies program parameters with a file. [optional]
#         Example:
#                 rolapSecurityTool -ds SimpleCube_DB2 -i securityImp.xml
#                 rolapSecurityTool -ds SimpleCube_DB2 -e securityExp.xml
#                 rolapSecurityTool -u hmiller -p hillock -n LDAP -ds SimpleCube_DB2 -e securityExp.xml
#                 rolapSecurityTool -params myParameters.txt

OS_NAME=`uname`
CWD=$PWD
SEP=":"

JAVA="../ibm-jre/jre/bin/java"
CRN_LIB_HOME="../webapps/p2pd/WEB-INF/lib"
CRN_CLASS_HOME="../webapps/p2pd/WEB-INF/classes"
CRN_BIN_HOME="../bin"

case "$OS_NAME" in
  "Linux"|"SunOS") 
    LD_LIBRARY_PATH=$CWD:$CWD/bind:$CWD/lib
    export LD_LIBRARY_PATH 
    ;;  
  "AIX") export LIBPATH=$CWD:$CWD/bind:$CWD/lib
    ;;
  "HP-UX") export SHLIB_PATH=$CWD:$CWD/bind:$CWD/lib
    ;;   
  "Windows_NT") SEP=";"
    ;;
esac

CLASSPATH="$CRN_CLASS_HOME$SEP$CRN_LIB_HOME/activation.jar$SEP$CRN_LIB_HOME/axis.jar$SEP$CRN_LIB_HOME/axisCrnpClient.jar$SEP$CRN_LIB_HOME/commons-discovery-0.2.jar$SEP$CRN_LIB_HOME/commons-logging-1.1.jar$SEP$CRN_LIB_HOME/commons-lang-2.6.jar$SEP$CRN_LIB_HOME/commons-configuration-1.9.jar$SEP$CRN_LIB_HOME/commons-beanutils.jar$SEP$CRN_LIB_HOME/commons-httpclient-3.1.jar$SEP$CRN_LIB_HOME/commons-codec.jar$SEP$CRN_LIB_HOME/CognosIPF.jar$SEP$CRN_LIB_HOME/jaxrpc.jar$SEP$CRN_LIB_HOME/p2pd.jar$SEP$CRN_LIB_HOME/cclcfgapi.jar$SEP$CRN_LIB_HOME/p2pd.jar$SEP$CRN_LIB_HOME/jaxen-1.1.1.jar$SEP$CRN_LIB_HOME/dom4j-2.1.1.jar$SEP$CRN_LIB_HOME/mail.jar$SEP$CRN_LIB_HOME/saaj.jar$SEP$CRN_LIB_HOME/dom4j.jar$SEP$CRN_LIB_HOME/xalan.jar$SEP$CRN_LIB_HOME/wsdl4j-1.5.1.jar$SEP$CRN_LIB_HOME/xqeService.jar$SEP$CRN_LIB_HOME/dom4j-2.1.1.jar$SEP$CRN_LIB_HOME/icu4j.jar$SEP$CRN_LIB_HOME/commons-collections-3.2.2.jar$SEP$CRN_LIB_HOME/logkit-1.2.jar$SEP$CRN_LIB_HOME/log4j-1.2.17.jar$SEP$CRN_LIB_HOME/CognosCCL4J.jar$SEP$CRN_BIN_HOME/jcam_jni.jar$SEP$CRN_LIB_HOME/zipi.jar$SEP$CRN_LIB_HOME/commons-parquet.jar$SEP$CRN_BIN_HOME/slf4j-api-1.7.23.jar$SEP$CRN_BIN_HOME/slf4j-nop-1.7.23.jar$SEP$CRN_LIB_HOME/commons-io-2.4.jar$SEP$CRN_LIB_HOME/bcprov.jar$SEP$CRN_LIB_HOME/bcpkix.jar"

$JAVA -classpath ".$SEP$CLASSPATH" com.cognos.xqe.runtree.olap.mdx.rolapprovider.security.tool.ROLAPSecurityTool "$@"