Commit 432393d60ef774eb41c12bb1ebddef733a5f5077

Authored by Fernando Ribeiro
1 parent d9ddfbe76c
Exists in OPENAIRE5.X

Changed openaire-refresh-list to handle the problem of mal formed xml if no data came from OpenAIRE.

Now it will create a temporary file and only updates if there is data and well fomed
setup-data/dspace-source/dspace/bin/openaire-refresh-list
... ... @@ -9,6 +9,10 @@ echo "Updating OpenAIRE Project list"
9 9  
10 10 # Read parameters from DSpace config
11 11 FILE=$($BINDIR/dspace dsrun org.dspace.core.ConfigurationManager -property openaire.projects.filename)
  12 +
  13 +### RCAAP - Create a temporary file with the projects from openaire
  14 +FILE_TMP="$FILE.tmp"
  15 +
12 16 ONLINE=$($BINDIR/dspace dsrun org.dspace.core.ConfigurationManager -property openaire.projects.url)
13 17  
14 18 ONLINE=$(echo $ONLINE | sed 's/\"//g')
... ... @@ -28,7 +32,10 @@ do
28 32 cp "$url" "${i}.xml"
29 33 fi
30 34  
31   - xmllint --format "${i}.xml" | head -n -2 > $FILE
  35 + #xmllint --format "${i}.xml" | head -n -2 > $FILE
  36 + ####RCAAP ADD TO A TMP FILE INSTEAD TO THE END FILE
  37 + xmllint --format "${i}.xml" | head -n -2 > $FILE_TMP
  38 +
32 39 rm "${i}.xml"
33 40  
34 41 i=$(($i+1))
... ... @@ -39,13 +46,29 @@ do
39 46 cp "$url" "${i}.xml"
40 47 fi
41 48  
42   - xmllint --format "${i}.xml" | head -n -2 | tail -n +4 >> $FILE
  49 + #xmllint --format "${i}.xml" | head -n -2 | tail -n +4 >> $FILE
  50 + ####RCAAP ADD TO A TMP FILE INSTEAD TO THE END FILE
  51 + xmllint --format "${i}.xml" | head -n -2 | tail -n +4 >> $FILE_TMP
43 52 rm "${i}.xml"
44 53  
45 54 i=$(($i+1))
46 55 fi
47 56 done
48 57  
49   -echo -e "\n$XML_CLOSE_ELEMENTS" >> $FILE
  58 +#echo -e "\n$XML_CLOSE_ELEMENTS" >> $FILE
  59 +####RCAAP ADD TO A TMP FILE INSTEAD TO THE END FILE
  60 +echo -e "\n$XML_CLOSE_ELEMENTS" >> $FILE_TMP
  61 +
  62 +#TEST IF XML IS WELL FORMED
  63 +xmllint --format --noout $FILE_TMP
  64 +
  65 +if [ $? -eq 0 ];
  66 +then
  67 + mv $FILE_TMP $FILE
  68 +fi
  69 +
  70 +rm -f $FILE_TMP
  71 +###END RCAAP
  72 +
50 73  
51 74 echo "> Ended \"$0\" execution."
... ...