- Looks like simply adding a new metadata field to `dspace/config/registries/cgiar-types.xml` and restarting DSpace causes the field to get added to the rregistry
- It requires a restart but at least it allows you to manage the registry programmatically
- It's not a very good way to manage the registry, though, as removing one there doesn't cause it to be removed from the registry, and we always restore from database backups so there would never be a scenario when we needed these to be created
- Testing some corrections on CCAFS Phase II flagships (`cg.subject.ccafs`):
- CCAFS said they want to wait on the flagship updates (`cg.subject.ccafs`) on CGSpace, perhaps for a month or so
- Help Marianne Gadeberg (WLE) with some user permissions as it seems she had previously been using a personal email account, and is now on a CGIAR one
- I manually added her new account to ~25 authorizations that her hold user was on
- Update rvm on DSpace Test and CGSpace as there was a [security disclosure about versions less than 1.28.0](https://github.com/justinsteven/advisories/blob/master/2017_rvm_cd_command_execution.md)
- We are using only ~8GB of RAM for applications, and 16GB for caches!
- The Linode machine we're on has 24GB of RAM but only because that's the only instance that had enough disk space for us (384GB)...
- We should probably look into Google Compute Engine or Digital Ocean where we can get more storage without having to follow a linear increase in instance pricing for CPU/memory as well
- Especially because we only use 2 out of 8 CPUs basically:
- Fix issue with duplicate declaration of in atmire-dspace-xmlui `pom.xml` (causing non-fatal warnings during the maven build)
- Experiment with making DSpace generate HTTPS handle links, first a change in dspace.cfg or the site's properties file:
```
handle.canonical.prefix = https://hdl.handle.net/
```
- And then a SQL command to update existing records:
```
dspace=# update metadatavalue set text_value = regexp_replace(text_value, 'http://hdl.handle.net', 'https://hdl.handle.net') where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'uri');
- I noticed a few items that have incorrect DOI links (`dc.identifier.doi`), and after looking in the database I see there are over 100 that are missing the scheme or are just plain wrong:
dspace=# select distinct text_value from metadatavalue where resource_type_id=2 and metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value not like 'http%://%';
dspace=# update metadatavalue set text_value = regexp_replace(text_value, '(^10\..+$)', 'https://dx.doi.org/\1') where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value like '10.%';
- This will get any that begin with `doi:10.` and change them to `https://dx.doi.org/10.x`:
```
dspace=# update metadatavalue set text_value = regexp_replace(text_value, '^doi:(10\..+$)', 'https://dx.doi.org/\1') where resource_type_id=2 and metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value like 'doi:10%';
- Fix DOIs like `dx.doi.org/10.` to be `https://dx.doi.org/10.`:
```
dspace=# update metadatavalue set text_value = regexp_replace(text_value, '(^dx.doi.org/.+$)', 'https://dx.doi.org/\1') where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value like 'dx.doi.org/%';
```
- Fix DOIs like `http//`:
```
dspace=# update metadatavalue set text_value = regexp_replace(text_value, '^http//(dx.doi.org/.+$)', 'https://dx.doi.org/\1') where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value like 'http//%';
```
- Fix DOIs like `dx.doi.org./`:
```
dspace=# update metadatavalue set text_value = regexp_replace(text_value, '(^dx.doi.org\./.+$)', 'https://dx.doi.org/\1') where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value like 'dx.doi.org./%'
```
- Delete some invalid DOIs:
```
dspace=# delete from metadatavalue where resource_type_id=2 and metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value in ('DOI','CPWF Mekong','Bulawayo, Zimbabwe','bb');
```
- Fix some other random outliers:
```
dspace=# update metadatavalue set text_value = 'https://dx.doi.org/10.1016/j.aquaculture.2015.09.003' where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value = 'http:/dx.doi.org/10.1016/j.aquaculture.2015.09.003';
dspace=# update metadatavalue set text_value = 'https://dx.doi.org/10.5337/2016.200' where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value = 'doi: https://dx.doi.org/10.5337/2016.200';
dspace=# update metadatavalue set text_value = 'https://dx.doi.org/doi:10.1371/journal.pone.0062898' where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value = 'Http://dx.doi.org/doi:10.1371/journal.pone.0062898';
dspace=# update metadatavalue set text_value = 'https://dx.doi.10.1016/j.cosust.2013.11.012' where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value = 'http:dx.doi.10.1016/j.cosust.2013.11.012';
dspace=# update metadatavalue set text_value = 'https://dx.doi.org/10.1080/03632415.2014.883570' where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value = 'org/10.1080/03632415.2014.883570';
dspace=# update metadatavalue set text_value = 'https://dx.doi.org/10.15446/agron.colomb.v32n3.46052' where metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value = 'Doi: 10.15446/agron.colomb.v32n3.46052';
```
- And do another round of `http://` → `https://` cleanups:
```
dspace=# update metadatavalue set text_value = regexp_replace(text_value, 'http://dx.doi.org', 'https://dx.doi.org') where resource_type_id=2 and metadata_field_id IN (select metadata_field_id from metadatafieldregistry where element = 'identifier' and qualifier = 'doi') and text_value like 'http://dx.doi.org%';
- Something to think about here is to write a [Curation Task](https://wiki.duraspace.org/display/DSDOC5x/Curation+System#CurationSystem-ScriptedTasks) in Java to do these sanity checks / corrections every night
- Then we could add a cron job for them and run them from the command line like:
- Testing the `fix-metadata-values.py` script on macOS and it seems like we don't need to use `.encode('utf-8')` anymore when printing strings to the screen
- It seems this might have only been a temporary problem, as both Python 3.5.2 and 3.6.0 are able to print the problematic string "Entwicklung & Ländlicher Raum" without the `encode()` call, but print it as a bytes when it *is* used:
- So for now I will remove the encode call from the script (though it was never used on the versions on the Linux hosts), leading me to believe it really *was* a temporary problem, perhaps due to macOS or the Python build I was using.