diff --git a/import-marc-auth.bat b/import-marc-auth.bat index d83294c5159c36efb06c6ad429e126c23861eaf4..e6b0004ac1e8113a8329c373b4346fce7dda9868 100644 --- a/import-marc-auth.bat +++ b/import-marc-auth.bat @@ -23,22 +23,6 @@ echo You need to set the VUFIND_HOME environmental variable before running this goto end :vufindhomefound -rem Always use the standard authority mappings; if the user specified an override -rem file, add that to the setting. -if not exist %VUFIND_LOCAL_DIR%\import\marc_auth.properties goto nolocalmappings -set MAPPINGS_FILE=%VUFIND_LOCAL_DIR%\import\marc_auth.properties -goto mappingsset -:nolocalmappings -set MAPPINGS_FILE=%VUFIND_HOME%\import\marc_auth.properties -:mappingsset -if "!%2!"=="!!" goto noextramappings -if not exist %VUFIND_LOCAL_DIR%\import\%2 goto nolocalextramappings -set MAPPINGS_FILE=%MAPPINGS_FILE%,%VUFIND_LOCAL_DIR%\import\%2 -goto noextramappings -:nolocalextramappings -set MAPPINGS_FILE=%MAPPINGS_FILE%,%VUFIND_HOME%\import\%2 -:noextramappings - rem Override some settings in the standard import script: if not exist %VUFIND_LOCAL_DIR%\import\import_auth.properties goto nolocalproperties set PROPERTIES_FILE=%VUFIND_LOCAL_DIR%\import\import_auth.properties @@ -47,8 +31,29 @@ goto propertiesfound set PROPERTIES_FILE=%VUFIND_HOME%\import\import_auth.properties :propertiesfound +rem Always use the authority mappings from PROPERTIES_FILE +rem if the user specified an override file, add that to the setting. +set MAPPINGS_FILENAMES="" +for /f "delims=" %%a in ('findstr "^solr.indexer.properties" %PROPERTIES_FILE%') do set MAPPINGS_FILENAMES=%%a +set MAPPINGS_FILENAMES="%MAPPINGS_FILENAMES:solr.indexer.properties=%" +if not "%2"=="" set MAPPINGS_FILENAMES=%MAPPINGS_FILENAMES%,%2 +set MAPPINGS_FILENAMES=%MAPPINGS_FILENAMES:"=% + +setlocal EnableDelayedExpansion +set MAPPINGS_FILES="" +for %%a in (%MAPPINGS_FILENAMES%) do ( + if not !MAPPINGS_FILES!=="" set MAPPINGS_FILES=!MAPPINGS_FILES!, + if exist %VUFIND_LOCAL_DIR%\import\%%a ( + set MAPPINGS_FILES=!MAPPINGS_FILES!%VUFIND_LOCAL_DIR%\import\%%a + ) else ( + set MAPPINGS_FILES=!MAPPINGS_FILES!%VUFIND_HOME%\import\%%a + ) +) +set MAPPINGS_FILES=%MAPPINGS_FILES:~2,99999% +setlocal DisableDelayedExpansion + set SOLRCORE="authority" -set EXTRA_SOLRMARC_SETTINGS="-Dsolr.indexer.properties=%MAPPINGS_FILE%" +set EXTRA_SOLRMARC_SETTINGS="-Dsolr.indexer.properties=%MAPPINGS_FILES%" rem Call the standard script: call %VUFIND_HOME%\import-marc.bat %1 diff --git a/import-marc-auth.sh b/import-marc-auth.sh index a67ce7f7ad16e122624d290ec5ae0f7194390d1c..d543d17c621dcf3d048c58e7ffb835141e9a15c8 100755 --- a/import-marc-auth.sh +++ b/import-marc-auth.sh @@ -26,34 +26,38 @@ then fi fi - -# Always use the standard authority mappings; if the user specified an override -# file, add that to the setting. -if [ -f "$VUFIND_LOCAL_DIR/import/marc_auth.properties" ] +# Override some settings in the standard import script: +if [ -f "$VUFIND_LOCAL_DIR/import/import_auth.properties" ] then - MAPPINGS_FILE="$VUFIND_LOCAL_DIR/import/marc_auth.properties" + export PROPERTIES_FILE="$VUFIND_LOCAL_DIR/import/import_auth.properties" else - MAPPINGS_FILE="$VUFIND_HOME/import/marc_auth.properties" + export PROPERTIES_FILE="$VUFIND_HOME/import/import_auth.properties" fi + +# Always use the authority mappings from PROPERTIES_FILE +# if the user specified an override file, add that to the setting. +MAPPINGS_FILENAMES=($(sed --quiet --expression='s/^\(solr.indexer.properties\s*=\s*\)\(.*\)/\2/p' $PROPERTIES_FILE | tr "," " ")) if [ $# -gt 1 ] then - if [ -f "$VUFIND_LOCAL_DIR/import/$2" ] + MAPPINGS_FILENAMES+=($2) +fi + +MAPPINGS_FILES="" +for MAPPINGS_FILENAME in ${MAPPINGS_FILENAMES[@]}; do + if [ -n "$MAPPINGS_FILES" ]; then + MAPPINGS_FILES+="," + fi + + if [ -f "$VUFIND_LOCAL_DIR/import/$MAPPINGS_FILENAME" ] then - MAPPINGS_FILE="$MAPPINGS_FILE,$VUFIND_LOCAL_DIR/import/$2" + MAPPINGS_FILES+="$VUFIND_LOCAL_DIR/import/$MAPPINGS_FILENAME" else - MAPPINGS_FILE="$MAPPINGS_FILE,$VUFIND_HOME/import/$2" + MAPPINGS_FILES+="$VUFIND_HOME/import/$MAPPINGS_FILENAME" fi -fi +done -# Override some settings in the standard import script: -if [ -f "$VUFIND_LOCAL_DIR/import/import_auth.properties" ] -then - export PROPERTIES_FILE="$VUFIND_LOCAL_DIR/import/import_auth.properties" -else - export PROPERTIES_FILE="$VUFIND_HOME/import/import_auth.properties" -fi export SOLRCORE="authority" -export EXTRA_SOLRMARC_SETTINGS="-Dsolr.indexer.properties=$MAPPINGS_FILE" +export EXTRA_SOLRMARC_SETTINGS="-Dsolr.indexer.properties=$MAPPINGS_FILES" # Call the standard script: -$VUFIND_HOME/import-marc.sh $1 \ No newline at end of file +$VUFIND_HOME/import-marc.sh $1