<p>Rough notes for importing the CGIAR Library content. It was decided that this content would go to a new top-level community called <em>CGIAR System Organization</em>.</p>
<li><inputchecked=""disabled=""type="checkbox"> Merge <ahref="https://github.com/ilri/DSpace/pull/339">#339</a> to <code>5_x-prod</code> branch and rebuild DSpace</li>
<li><inputchecked=""disabled=""type="checkbox"> Increase <code>max_connections</code> in <code>/etc/postgresql/9.5/main/postgresql.conf</code> by ~10
<ul>
<li><code>SELECT * FROM pg_stat_activity;</code> seems to show ~6 extra connections used by the command line tools during import</li>
</ul>
</li>
<li><inputchecked=""disabled=""type="checkbox"> Temporarily disable nightly <code>index-discovery</code> cron job because the import process will be taking place during some of this time and I don’t want them to be competing to update the Solr index</li>
</code></pre><p><strong>Import to CGSpace (also see <ahref="http://alanorth.github.io/cgspace-notes/2017-05/#2017-05-10">notes from 2017-05-10</a>):</strong></p>
<ul>
<li><inputchecked=""disabled=""type="checkbox"> Copy all exports from DSpace Test</li>
<li><inputchecked=""disabled=""type="checkbox"> Add ingestion overrides to <code>dspace.cfg</code> before import:</li>
<li><inputchecked=""disabled=""type="checkbox"> Import communities and collections, paying attention to options to skip missing parents and ignore handles:</li>
$ for collection in 10947-1/COLLECTION@10947-*; do dspace packager -s -o ignoreHandle=false -t AIP -e aorth@mjanja.ch -p 10947/1 $collection; done
$ for item in 10947-1/ITEM@10947-*; do dspace packager -r -f -u -t AIP -e aorth@mjanja.ch $item; done
</code></pre><p>This submits AIP hierarchies recursively (-r) and suppresses errors when an item’s parent collection hasn’t been created yet—for example, if the item is mapped. The large historic archive (10947/1) is created in several steps because it requires a lot of memory and often crashes.</p>
<p><strong>Create new subcommunities and collections for content we reorganized into new hierarchies from the original:</strong></p>
<ul>
<li><inputchecked=""disabled=""type="checkbox"> Create <em>CGIAR System Management Board</em> sub-community: <code>10568/83536</code>
<ul>
<li><inputchecked=""disabled=""type="checkbox"> Content from <em>CGIAR System Management Board documents</em> collection (<code>10947/4561</code>) goes here</li>
<li>Import collection hierarchy first and then the items:</li>
$ for item in 10568-93760/ITEM@10947-465*; do dspace packager -r -f -u -t AIP -e aorth@mjanja.ch $item; done
</code></pre><ul>
<li><inputchecked=""disabled=""type="checkbox"> Create <em>CGIAR System Management Office</em> sub-community: <code>10568/83537</code>
<ul>
<li><inputchecked=""disabled=""type="checkbox"> Create <em>CGIAR System Management Office documents</em> collection: <code>10568/83538</code></li>
<li>Import items to collection individually in replace mode (-r) while explicitly preserving handles and ignoring parents:</li>
</ul>
</li>
</ul>
<pretabindex="0"><code>$ for item in 10568-93759/ITEM@10947-46*; do dspace packager -r -t AIP -o ignoreHandle=false -o ignoreParent=true -e aorth@mjanja.ch -p 10568/83538 $item; done
</code></pre><p><strong>Get the handles for the last few items from CGIAR Library that were created since we did the migration to DSpace Test in May:</strong></p>
<pretabindex="0"><code>dspace=# select handle from item, handle where handle.resource_id = item.item_id AND item.item_id in (select item_id from metadatavalue where metadata_field_id=11 and date(text_value) >'2017-05-01T00:00:00Z');
</code></pre><ul>
<li>Export them from the CGIAR Library:</li>
</ul>
<pretabindex="0"><code># for handle in 10947/4658 10947/4659 10947/4660 10947/4661 10947/4665 10947/4664 10947/4666 10947/4669; do /usr/local/dspace/bin/dspace packager -d -a -t AIP -e m.marus@cgiar.org -i $handle ${handle}.zip; done
</code></pre><ul>
<li>Import on CGSpace:</li>
</ul>
<pretabindex="0"><code>$ for item in 10947-latest/*.zip; do dspace packager -r -u -t AIP -e aorth@mjanja.ch $item; done
<li><inputchecked=""disabled=""type="checkbox"> Shut down Tomcat and run <code>update-sequences.sql</code> as the system’s <code>postgres</code> user</li>
<li><inputchecked=""disabled=""type="checkbox"> Remove ingestion overrides from <code>dspace.cfg</code></li>
<li><inputchecked=""disabled=""type="checkbox"> Reset PostgreSQL <code>max_connections</code> to 183</li>
<li><inputchecked=""disabled=""type="checkbox"> Adjust CGSpace’s <code>handle-server/config.dct</code> to add the new prefix alongside our existing 10568, ie:</li>
</code></pre><p>I had been regenerated the <code>sitebndl.zip</code> file on the CGIAR Library server and sent it to the Handle.net admins but they said that there were mismatches between the public and private keys, which I suspect is due to <code>make-handle-config</code> not being very flexible. After discussing our scenario with the Handle.net admins they said we actually don’t need to send an updated <code>sitebndl.zip</code> for this type of change, and the above <code>config.dct</code> edits are all that is required. I guess they just did something on their end by setting the authoritative IP address for the 10947 prefix to be the same as ours…</p>
<ul>
<li><inputchecked=""disabled=""type="checkbox"> Update DNS records:
<ul>
<li>CNAME: cgspace.cgiar.org</li>
</ul>
</li>
<li><inputchecked=""disabled=""type="checkbox"> Re-deploy DSpace from freshly built <code>5_x-prod</code> branch</li>
<li><inputchecked=""disabled=""type="checkbox"> Merge <code>cgiar-library</code> branch to <code>master</code> and re-run ansible nginx templates</li>
<li><inputchecked=""disabled=""type="checkbox"> Run system updates and reboot server</li>
<li><inputchecked=""disabled=""type="checkbox"> Switch to Let’s Encrypt HTTPS certificates (after DNS is updated and server isn’t busy):</li>
<h3id="foreign-key-error-in-dspace-cleanup">Foreign Key Error in <code>dspace cleanup</code></h3>
<p>The cleanup script is sometimes used during import processes to clean the database and assetstore after failed AIP imports. If you see the following error with <code>dspace cleanup -v</code>:</p>
<pretabindex="0"><code>Error: ERROR: update or delete on table "bitstream" violates foreign key constraint "bundle_primary_bitstream_id_fkey" on table "bundle"
Detail: Key (bitstream_id)=(119841) is still referenced from table "bundle".
</code></pre><p>The solution is to set the <code>primary_bitstream_id</code> to NULL in PostgreSQL:</p>
<pretabindex="0"><code>dspace=# update bundle set primary_bitstream_id=NULL where primary_bitstream_id in (119841);
</code></pre><h3id="psqlexception-during-aip-ingest">PSQLException During AIP Ingest</h3>
<p>After a few rounds of ingesting—possibly with failures—you might end up with inconsistent IDs in the database. In this case, during AIP ingest of a single collection in submit mode (-s):</p>
<pretabindex="0"><code>org.dspace.content.packager.PackageValidationException: Exception while ingesting 10947-2527/10947-2527.zip, Reason: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "handle_pkey"
Detail: Key (handle_id)=(86227) already exists.
</code></pre><p>The normal solution is to run the <code>update-sequences.sql</code> script (with Tomcat shut down) but it doesn’t seem to work in this case. Finding the maximum <code>handle_id</code> and manually updating the sequence seems to work:</p>
<pretabindex="0"><code>dspace=# select * from handle where handle_id=(select max(handle_id) from handle);