Table of Contents
This page is in the 'old' namespace, and was imported from our previous wiki. We recommend checking for more up-to-date information using the search box.
Inserting metadata into a live collection using metadata-server.pl
This functionality is only available in versions of Greenstone newer than 2.83.
The metadata-server.pl script inserts the new value into the metadata.xml in the import directory and the collection.gdb file in the index directory Important: it only updates the live metadata display; the search index and classifiers will not be updated until the collection is rebuilt. Collection administrator will have to rebuild the collection to see the changes. In our example, we set up a cron job to rebuild the collection every-night.
Before starting
- Change the permission on the "index" directory to writable by the web server
- Change the permission on the "import" directory to writable by the web server
- Add custom macros folder and extra.dm, and add two Global macros
_rebuildpendingmessage_ (This will appear on top of the newly added metadata value to remind user this piece of information is not searchable) _newline_ (New line characters in the inserted metadata value will be replaced by this macro)
Calling the script
metadata-server.pl has the following arguments:
- a=insert-metadata
- un=[Username] - The authentication is not enabled at the moment, collection developers will have to handle the authentication themselves
- c=[Collection Shortname]
- d=[Document ID] - In format statement, it is referred as [DocOID]
- metaname=[Metadata Field Name]
- metavalue=[New Metadata Value] - This new value will be appended at the end
It returns following message on success
insert-metadata successful: Key[D0] [In metadata.xml] giv.submittedText = new metadata value [In database] giv.submittedText = _rebuildpendingmessage_new metadata value The new text has not been indexed, rebuilding collection is required
You need to customize your collection interface to have an AJAX call to this script when user submit new values. This AJAX call will have to evaluate the return value of the script to determine if that was successful. The possible error messages:
- Collection is locked (see Locking Section)
- Missing compulsory arguments
- Don't have permission to write to metadata.xml file
- Don't have permission to write to database file
- Invalid metadata.xml file
Locking
This script shares the same lock as the GLI:
- If GLI is using the collection, this script will be locked.
- On the other hand, while this script is in progress, GLI will not be able to access this collection.
- Two users can not run the script at the same time as one of them will be locked out.
- It is the caller's responsibility to retry the submit process.