From 1ce852466c967ed8551d7ef82b8aeb6af83bdcac Mon Sep 17 00:00:00 2001
From: Tom Scavo <trscavo@internet2.edu>
Date: Sat, 6 May 2017 17:00:51 -0400
Subject: [PATCH] Compute list of IdP DisplayNames

---
 bin/process_main_aggregate.sh | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/bin/process_main_aggregate.sh b/bin/process_main_aggregate.sh
index aef16d0..e8a566a 100755
--- a/bin/process_main_aggregate.sh
+++ b/bin/process_main_aggregate.sh
@@ -27,6 +27,7 @@ display_help () {
 	
 	  $csv_filename1
 	  $csv_filename2
+	  $csv_filename3
 	
 	The script is intended to be run as a cron job. It can (and
 	should) be run often, to pick up the latest changes to metadata.
@@ -108,8 +109,9 @@ if [ -z "$LOG_LEVEL" ]; then
 fi
 
 # output filenames
-csv_filename1="all-idps-rands.csv"
-csv_filename2="all-sps-rands.csv"
+csv_filename1="all-idp-displaynames.csv"
+csv_filename2="all-idps-rands.csv"
+csv_filename3="all-sps-rands.csv"
 
 #######################################################################
 # Process command-line options and arguments
@@ -182,16 +184,21 @@ if [ $status_code -ne 0 ]; then
 fi
 
 # XSL stylesheets must exist
-xsl_file1=$LIB_DIR/list_all_RandS_IdPs_csv.xsl
+xsl_file1=$LIB_DIR/list_all_IdP_DisplayNames_csv.xsl
 if [ ! -f "$xsl_file1" ]; then
 	echo "ERROR: $script_name: lib file does not exist: $xsl_file1" >&2
 	exit 2
 fi
-xsl_file2=$LIB_DIR/list_all_RandS_SPs_csv.xsl
+xsl_file2=$LIB_DIR/list_all_RandS_IdPs_csv.xsl
 if [ ! -f "$xsl_file2" ]; then
 	echo "ERROR: $script_name: lib file does not exist: $xsl_file2" >&2
 	exit 2
 fi
+xsl_file3=$LIB_DIR/list_all_RandS_SPs_csv.xsl
+if [ ! -f "$xsl_file3" ]; then
+	echo "ERROR: $script_name: lib file does not exist: $xsl_file3" >&2
+	exit 2
+fi
 
 # create a temporary subdirectory
 tmp_dir="${TMPDIR%%/}/${script_name%%.*}_$$"
@@ -208,6 +215,7 @@ xml_file="${tmp_dir}/saml-metadata.xml"
 # output files
 csv_file1="${tmp_dir}/$csv_filename1"
 csv_file2="${tmp_dir}/$csv_filename2"
+csv_file3="${tmp_dir}/$csv_filename3"
 
 #######################################################################
 # Main processing
@@ -251,9 +259,18 @@ if [ $exit_code -ne 0 ]; then
     clean_up_and_exit -d "$tmp_dir" $exit_code
 fi
 
+# create the third output file
+print_log_message -D "$script_name writing output file: $csv_file3"
+/usr/bin/xsltproc $xsl_file3 $xml_file > $csv_file3
+exit_code=$?
+if [ $exit_code -ne 0 ]; then
+	print_log_message -E "$script_name: xsltproc failed ($exit_code) on stylesheet: $xsl_file3"
+    clean_up_and_exit -d "$tmp_dir" $exit_code
+fi
+
 # move the output files to the web directory
 print_log_message -D "$script_name moving output files to dir: $out_dir"
-/bin/mv $csv_file1 $csv_file2 $out_dir
+/bin/mv $csv_file1 $csv_file2 $csv_file3 $out_dir
 exit_code=$?
 if [ $exit_code -ne 0 ]; then
 	print_log_message -E "$script_name: mv failed ($exit_code) to dir: $out_dir"