Dokumentation zur GokbSync-Programmierung
- Arbeitsweise der Skripte:
- $GOKB_HOME/scripts/GOKbSyncBase.groovy
- Über Grape maven repository dependencies einfügen
- JSON-Funktionalitäten einbinden
- Alle Funktionalitäten in Klasse GOKbSyncBase kapseln
- Source definieren
- Endpunkt {+}http://gokb.openlibraryfoundation.org/+
- Antwort erfolgt in XML
- Target definieren
- Endpunkt {+}http://localhost:8080/+
- Antwort erfolgt in JSON
- getTarget() // HTTP-Builder für Target instanziieren
- getSource() // HTTP-Builder für Source instanziieren
- loadConfig() // Config-Datei erstellen
- cfg_file: GOKbSyncBase-cfg.json
- config über JsonSlurper aus cfg_file ziehen
- Aufruf saveConfig()
- saveConfig() // config in cfg_file abspeichern
sendToTarget(Map parameters = [:], def successClosure = null) // Daten an Target senden
- Probelauf, wenn dryRun gesetzt ist
- Aufruf getTarget() // Target holen
- POST-Request mit JSON-Format an Target senden
- Fehler abfangen
returnData[:] zurückgeben
fetchFromSource(Map parameters = [:], def successClosure = null) // Daten von Source ziehen
- Aufruf getSource() // Source holen
- GET-Request an Source senden
- handleFile <= closure { fa ->
- fileMap <= Aufruf addCoreItems(fa)
- Aufruf directAddFields(fa, ...) }
- handleSource <= closure { source ->
- fileMap <= Aufruf addCoreItems(source)
- Aufruf directAddFields(source, ...) }
directAddFields(def data, Collection<String> fields = [], Map addTo = [:])
addCoreItems(def data, Map addTo = [:])
- Aufruf handleFile
- cleanup()
- run()
- runCode()
- $GOKB_HOME/scripts/sync_gokb_titles.groovy
- Source-Pfad: '/gokb/oai/titles'
PROBLEME beim Ausführen von GOKbSyncBase.groovy
ERROR org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during conversion: Error grabbing Grapes – [download failed: commons-logging#commons-logging;1.2!commons-logging.jar, download failed: commons-beanutils#commons-beanutils;1.8.0!commons-beanutils.jar, download failed: commons-lang#commons-lang;2.4!commons-lang.jar, download failed: xalan#xalan;2.7.2!xalan.jar, download failed: commons-codec#commons-codec;1.10!commons-codec.jar, download failed: xerces#xercesImpl;2.11.0!xercesImpl.jar, download failed: xml-apis#xml-apis;1.4.01!xml-apis.jar]
Die aufgetretenen Probleme hängen mit dem Einbinden diverser Libraries per Grape zusammen. Abhilfe soll die Konfiguration von Grape ~/.groovy/grapeConfig.xml schaffen.
LÖSUNGSVERSUCH <span style="color: #0000ee"><a href="http://stackoverflow.com/questions/16871792/groovy-grab-download-failed:" class="external-link" rel="nofollow">http://stackoverflow.com/questions/16871792/groovy-grab-download-failed:+</a></span>
It looks like your Grape settings are set only to look in your local .m2 directory for the library. Check your grapeConfig.xml configuration file. (If you don't have one, you can create it--it should go in the same directory where your groovysh.history and grapes cache directory are created by Groovy.) You can copy the example file shown on the Groovy Grape reference page. => <span style="color: #0000ee"><a href="http://docs.groovy-lang.org/latest/html/documentation/grape.html#Grape-CustomizeIvysettings" class="external-link" rel="nofollow">http://docs.groovy-lang.org/latest/html/documentation/grape.html#Grape-CustomizeIvysettings+</a></span>
=> <span style="color: #0000ee"><a href="http://mrhaki.blogspot.de/2009/09/groovy-goodness-grab-that-dependency.html" class="external-link" rel="nofollow">http://mrhaki.blogspot.de/2009/09/groovy-goodness-grab-that-dependency.html+</a></span>
If that doesn't help, I would try deleting your grapes cache directory and try it again.
$ grape list // get a list of all dependencies on local computer Wie in Lösungsversuch beschrieben grapeConfig.xml erstellt.
VORGEHENSWEISE
Im Ordner $GOKB_HOME/scripts liegen zahlreiche Skripte.
Zur Synchronisation Zwischen GOKb-Instanzen das Skript full_migration.sh anstoßen.
Dieses ruft dann intern
- sync_gokb_orgs.groovy
- sync_gokb_sources.groovy
- sync_gokb_titles.groovy
- sync_gokb_packages.groovy
Konfigurations-Files werden angelegt:
- sync-gokb-orgs-cfg.json
- sync-gokb-titles-cfg.json
Jedes einzelne Skript bindet GOKbSyncBase ein und ruft dessen Methoden auf
- fetchFromSource()
- eine Map mit einen Pfad als Inhalt
- ein Closure
- sendToTarget()
- eine Map mit einen Pfad als Inhalt
- ein Closure
Monit (phaeton-dev):
Der GOKB Sync läuft autmatisch über Monit auf phaeton-dev. Monit ruft zwischen 6-20 Uhr alle 5 Minuten folgenden Skripte auf:
/opt/laser/gokbSync/initSync.sh
Über Monit kann man dann den Sync stoppen (Disable Monitoring) oder starten (Enable Monitoring) (GokbSyncScript). -> {+}http://193.30.112.30:5141/GokbSyncScript+