Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6c668e8
Ignore temporal and output files.
michal-ruzicka Mar 6, 2015
98bdd83
Do not consider X-server working unless HTTP response is correct.
michal-ruzicka Mar 6, 2015
04dca0d
Do not consider REST API working unless HTTP response is correct.
michal-ruzicka Mar 6, 2015
1a20116
Validate validate.pl command line arguments.
michal-ruzicka Mar 6, 2015
89f90e3
Check $ENV{WWW_HOST} before use.
michal-ruzicka Mar 6, 2015
0f14d80
Fix calling of ‘validate.pl’ from ‘install_adapter.pl’.
michal-ruzicka Mar 6, 2015
6c628c1
Formatting of outputs.
michal-ruzicka Mar 6, 2015
e01ba0c
Major source code reformatting.
michal-ruzicka Mar 6, 2015
f103501
Correctly formated documentation in one place.
michal-ruzicka Mar 8, 2015
7653e7c
Remove execution flag from template files.
michal-ruzicka Mar 6, 2015
fdfc67d
Use sane varibale names.
michal-ruzicka Mar 6, 2015
41745aa
Better verification and escaping of parameters.
michal-ruzicka Mar 8, 2015
4703de4
More reliable Aleph version string detection.
michal-ruzicka Mar 8, 2015
840021d
Fix install_adapter.pl template processing.
michal-ruzicka Mar 8, 2015
4adf01d
Autoconfiguration of sql_lookup use.
michal-ruzicka Mar 8, 2015
e27f248
SQL lookup better search term debugging string.
michal-ruzicka Mar 8, 2015
ccb43a8
SQL lookup more suitable for use with Oracle read-only user.
michal-ruzicka Mar 8, 2015
2a4ee84
More reliable system currency detection.
michal-ruzicka Mar 8, 2015
05f9140
Ask for the locale value during the installation.
michal-ruzicka Mar 19, 2015
1dffd5a
Generate correct timezone names.
michal-ruzicka Mar 19, 2015
3b4b8dd
Do not leak script name / IP address for unauthorized users.
michal-ruzicka Apr 25, 2015
24a327e
Rename $patron_id -> $object_id.
michal-ruzicka Apr 25, 2015
94bf42d
Rename sql_lookup.cgi to sql_lookup.pl.
michal-ruzicka Apr 25, 2015
91692ff
More coding style fixes – proper params escaping etc.
michal-ruzicka Apr 25, 2015
7d104e4
Add code for inspection of used REST API functions.
michal-ruzicka Apr 25, 2015
c13d76f
Allow rewriting of URL prefixes in REST API responses.
michal-ruzicka Apr 25, 2015
cb0bc34
Fix URL rewriting.
michal-ruzicka Apr 25, 2015
8a70929
Exit correctly if no user parameters are passed to the script.
michal-ruzicka Apr 26, 2015
ef92e3b
Fix typos in error messages.
michal-ruzicka Apr 26, 2015
c876106
Fix typo in category check.
michal-ruzicka Apr 26, 2015
31285e6
Fix REST URL decomposition.
michal-ruzicka Apr 26, 2015
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Vim temp files.
.*.swp

# Output files
api_adapter.cgi
get_aleph_info.csh
sql_lookup.cgi
sql_lookup.csh
sql_lookup.txt
Binary file removed Aleph_API_Adapter_Users_Guide_v1.6.docx
Binary file not shown.
569 changes: 219 additions & 350 deletions README.md

Large diffs are not rendered by default.

528 changes: 324 additions & 204 deletions api_adapter.template
100755 → 100644

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions get_aleph_info.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
source /exlibris/aleph/VER/alephm/.cshrc >/dev/null
ver
echo $local_currency

# vim:textwidth=80:expandtab:tabstop=4:shiftwidth=4:fileencodings=utf8:spelllang=en
215 changes: 118 additions & 97 deletions install_adapter.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,168 +3,189 @@
use strict;
use warnings;

my $input_file1 = 'get_aleph_info.template';
my $output_file1 = 'get_aleph_info.csh';
use Fcntl qw( :mode );

my $input_file2 = 'api_adapter.template';
my $output_file2 = 'api_adapter.cgi';
my $get_aleph_info_template_file = 'get_aleph_info.template';
my $get_aleph_info_file = 'get_aleph_info.csh';

my $input_file3 = 'sql_lookup.csh.template';
my $output_file3 = 'sql_lookup.csh';
my $api_adapter_template_file = 'api_adapter.template';
my $api_adapter_file = 'api_adapter.cgi';

my $input_file4 = 'sql_lookup.cgi.template';
my $output_file4 = 'sql_lookup.cgi';
my $sql_lookup_template_file = 'sql_lookup.csh.template';
my $sql_lookup_file = 'sql_lookup.csh';

my $sql_lookup_pl_template_file = 'sql_lookup.pl.template';
my $sql_lookup_pl_file = 'sql_lookup.pl';

#-------------------------------------------
# Extract the version token from the path
#-------------------------------------------
my $string = $ENV{PWD};
my $ver = substr($string,16,5);
$ver =~ s/u/a/i;
my $current_user_home_dir = $ENV{HOME};
my $ver;
if ($current_user_home_dir =~ /[au]([^\/]+?)\/alephm$/) {
$ver = "a$1";
} else {
die "Unable to extract Aleph version from the current user \$HOME path\n";
}

#-----------------------------------------------------
# Prompt the installer for the institution's name.
# Prompt the installer for the institution's name.
#-----------------------------------------------------
my $instname = display(\"\nPlease enter the name of your institution (q=quit): ");

#-----------------------------------------------------
# Prompt the installer for the locale.
#-----------------------------------------------------
my $locale = display(\"\nPlease enter the locale (e.g. 'en_US') of your system installation (q=quit): ");

#-----------------------------------------------------------
# Prompt the installer for Aleph's REST API port number.
# Prompt the installer for Aleph's REST API port number.
#-----------------------------------------------------------
my $jboss_port = display(\"\nPlease enter the JBOSS port number for Aleph's REST API (q=quit): ");

#-------------------------------------------------------------------
# Prompt the installer for the license status of Aleph's X-server.
# Prompt the installer for the license status of Aleph's X-server.
#-------------------------------------------------------------------
my $xsl = display(\"\nIs the X-server licensed for use on this server <y/n>? ");
if (grep /y/i, $xsl) {$xsl = 1} else {$xsl = 0}

#----------------------------------------------------------
# Store this indicator for later reading by validate.pl.
#----------------------------------------------------------
open(FH1,">sql_lookup.txt");
print FH1 "$xsl\n";
close(FH1);
open(OUTPUT,">sql_lookup.txt");
print OUTPUT "$xsl\n";
close(OUTPUT);

my $db_schema;
my $db_user;
my $db_password;
my $z308_prefix;
if (!$xsl) {
#-------------------------------------------------------------------
# Prompt the installer for the Oracle user id of the ADM library,
# usually <xxx>50, and that user's Oracle password.
#-------------------------------------------------------------------
$db_user = display(\"\nPlease enter the Oracle user id for the ADM library (usually <xxx>50): ");
#-------------------------------------------------------------------
# Prompt the installer for the Oracle user id of the ADM library,
# usually <xxx>50, and that user's Oracle password.
#-------------------------------------------------------------------
$db_schema = display(\"\nPlease enter the Oracle schema id for the USR library (usually <xxx>00): ");

$db_user = display(\"\nPlease enter the Oracle user id with the right reading $db_schema.Z308 table: ");

$db_password = display(\"\nPlease enter the Oracle password for user id $db_user: ");
$db_password = display(\"\nPlease enter the Oracle password for user id $db_user: ");

$z308_prefix = display(\"\nPlease enter the two-number 'type' prefix from the Z308 Oracle table that corresponds with the identifiers that will be submitted for lookup: ");
}
$z308_prefix = display(\"\nPlease enter the two-number 'type' prefix from the $db_schema.Z308 Oracle table that corresponds with the identifiers that will be submitted for lookup: ");
}

#-------------------------------------------------------------
# Prompt the installer for a patron's Aleph id to be used
# in testing access to the X-server and REST API.
# Prompt the installer for a patron's Aleph id to be used
# in testing access to the X-server and REST API.
#-------------------------------------------------------------
my $aleph_id;
if ($xsl) {
$aleph_id = display(\"\nPlease enter a patron's Aleph id that can be used to test access to the X-server and the REST API: ");
}
else {
$aleph_id = display(\"\nPlease enter a patron's Aleph id that can be used to test access to the REST API: ");
}
$aleph_id = display(\"\nPlease enter a patron's Aleph id that can be used to test access to the X-server and the REST API: ");
} else {
$aleph_id = display(\"\nPlease enter a patron's Aleph id that can be used to test access to the REST API: ");
}

#-------------------------------------------------------------------
# Prompt the installer for the IP addresses of the remote servers
# that will call the adapter. These IP addresses will be inserted
# into the adapter's whitelist.
# into the adapter's whitelist.
#-------------------------------------------------------------------
my $ip_string = display(\"\nPlease enter the IP addresses of the remote servers that will call the adapter. Separate multiple addresses with commas e.g. 10.10.10.10,11.11.11.11 etc.\n");
my @ip_addresses = split /,/, $ip_string;
foreach (@ip_addresses) {
$_ = join '', "'", $_, "'"
}
$_ = join '', "'", $_, "'"
}
$ip_string = join ',', @ip_addresses;

#----------------------------------------------------------------------
# Generate the get_aleph_info.csh script from a template.
# Substitute the version token into the path of the 'source' command.
#----------------------------------------------------------------------
open(FH1,"<$input_file1") or die "Unable to open input file $input_file1\n";
open(FH2,">$output_file1") or die "Unable to open output file $output_file1\n";
while (<FH1>) {
if (grep /source/, $_) {
$_ =~ s/VER/$ver/g;
}
print FH2;
}
`chmod +x $output_file1`;
close(FH1);
close(FH2);
open(TEMPLATE,"<$get_aleph_info_template_file") or die "Unable to open input file $get_aleph_info_template_file\n";
open(OUTPUT,">$get_aleph_info_file") or die "Unable to open output file $get_aleph_info_file\n";
while (<TEMPLATE>) {
if (grep /source/, $_) {
$_ =~ s/VER/$ver/g;
}
print OUTPUT;
}
close(TEMPLATE);
close(OUTPUT);
chmod(S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, "${get_aleph_info_file}");

#----------------------------------------------------------
# Generate the api_adapter.cgi script from a template.
# Substitute the IP addresses into the whitelist.
# Substitute the IP addresses into the whitelist.
#----------------------------------------------------------
open(FH1,"<$input_file2") or die "Unable to open input file $input_file2\n";
open(FH2,">$output_file2") or die "Unable to open output file $output_file2\n";
while (<FH1>) {
if (grep /WHITELIST/, $_) { $_ =~ s/WHITELIST/$ip_string/g }
if (grep /PORT/, $_) { $_ =~ s/PORT/$jboss_port/og }
if (grep /INSTNAME/, $_) { $_ =~ s/INSTNAME/$instname/og }
print FH2;
}
`chmod +x $output_file2`;
close(FH1);
close(FH2);
open(TEMPLATE,"<$api_adapter_template_file") or die "Unable to open input file $api_adapter_template_file\n";
open(OUTPUT,">$api_adapter_file") or die "Unable to open output file $api_adapter_file\n";
while (<TEMPLATE>) {
if (grep /WHITELIST/, $_) { $_ =~ s/WHITELIST/$ip_string/g }
if (grep /PORT/, $_) { $_ =~ s/PORT/$jboss_port/og }
if (grep /INSTNAME/, $_) { $_ =~ s/INSTNAME/$instname/og }
if (grep /LOCALE/, $_) { $_ =~ s/LOCALE/$locale/og }
$_ = "${1}1${2}" if ($_ =~ /^(\s*my\s*\$sql_lookup\s*=\s*)\d(;\s*)$/);
print OUTPUT;
}
close(TEMPLATE);
close(OUTPUT);
chmod(S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, "${api_adapter_file}");

#---------------------------------------------------------------
# Optionally, generate the SQL lookup scripts from templates.
#---------------------------------------------------------------
if (!$xsl) {
#----------------------------------------------------------------------------
# Generate the sql_lookup.csh script from a template.
# Substitute the version token into the path of the 'source' command.
#----------------------------------------------------------------------------
open(FH1,"<$input_file3") or die "Unable to open input file $input_file3\n";
open(FH2,">$output_file3") or die "Unable to open output file $output_file3\n";
while (<FH1>) {
if (grep /VER/, $_) { $_ =~ s/VER/$ver/g }
}
close(FH1);
close(FH2);

#---------------------------------------------------------
# Generate the sql_lookup.cgi script from a template.
# Substitute Oracle user id and password, Z308 prefix.
#---------------------------------------------------------
open(FH1,"<$input_file4") or die "Unable to open input file $input_file4\n";
open(FH2,">$output_file4") or die "Unable to open output file $output_file4\n";
while (<FH1>) {
if (grep /DBUSER/, $_) { $_ =~ s/DBUSER/$db_user/g }
if (grep /DBPASSWORD/, $_) { $_ =~ s/DBPASSWORD/$db_password/g }
if (grep /Z308PRE/, $_) { $_ =~ s/Z308PRE/$z308_prefix/g }
}
close(FH1);
close(FH2);
}
#----------------------------------------------------------------------------
# Generate the sql_lookup.csh script from a template.
# Substitute the version token into the path of the 'source' command.
#----------------------------------------------------------------------------
open(TEMPLATE,"<$sql_lookup_template_file") or die "Unable to open input file $sql_lookup_template_file\n";
open(OUTPUT,">$sql_lookup_file") or die "Unable to open output file $sql_lookup_file\n";
while (<TEMPLATE>) {
if (grep /VER/, $_) { $_ =~ s/VER/$ver/g }
print OUTPUT;
}
close(TEMPLATE);
close(OUTPUT);
chmod(S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, "${sql_lookup_file}");

#---------------------------------------------------------
# Generate the sql_lookup.pl script from a template.
# Substitute Oracle user id and password, Z308 prefix.
#---------------------------------------------------------
open(TEMPLATE,"<$sql_lookup_pl_template_file") or die "Unable to open input file $sql_lookup_pl_template_file\n";
open(OUTPUT,">$sql_lookup_pl_file") or die "Unable to open output file $sql_lookup_pl_file\n";
while (<TEMPLATE>) {
if (grep /DBSCHEMA/, $_) { $_ =~ s/DBSCHEMA/$db_schema/g }
if (grep /DBUSER/, $_) { $_ =~ s/DBUSER/$db_user/g }
if (grep /DBPASSWORD/, $_) { $_ =~ s/DBPASSWORD/$db_password/g }
if (grep /Z308PRE/, $_) { $_ =~ s/Z308PRE/$z308_prefix/g }
print OUTPUT;
}
close(TEMPLATE);
close(OUTPUT);
chmod(S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, "${sql_lookup_pl_file}");
}

#----------------------------
# Validate the installation
#----------------------------
print "Validating the installation\n";
my @messages = `validate.pl $aleph_id $jboss_port`;
print "\n### Validating the installation ###\n";
my @messages = `./validate.pl $aleph_id $jboss_port`;
foreach (@messages) { print }
exit;

#------------------ Subroutines ------------------
sub display {
my $text_ref = pop;
my $input = '';
while (lc $input ne 'y' && lc $input ne 'n' && lc $input ne 's' && $input eq '') {
print STDOUT "$$text_ref";
$input = <STDIN>;
chomp $input;
}
if ($input eq 'q') { exit }
return $input;
}

my $text_ref = pop;
my $input = '';
while (lc $input ne 'y' && lc $input ne 'n' && lc $input ne 's' && $input eq '') {
print STDOUT "$$text_ref";
$input = <STDIN>;
chomp $input;
}
if ($input eq 'q') { exit }
return $input;
}

# vim:textwidth=80:expandtab:tabstop=4:shiftwidth=4:fileencodings=utf8:spelllang=en
50 changes: 0 additions & 50 deletions sql_lookup.cgi.template

This file was deleted.

6 changes: 4 additions & 2 deletions sql_lookup.csh.template
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/tcsh
source /exlibris/aleph/VER/alephm/.cshrc >/dev/null
set parm1 = $1
perl sql_lookup.cgi $parm1
set parm1 = "$1"
perl sql_lookup.pl "$parm1"

# vim:textwidth=80:expandtab:tabstop=4:shiftwidth=4:fileencodings=utf8:spelllang=en
Loading