From 6f07bc560fc2e32c7d7d7afad5e1e32c9a0f70ac Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Fri, 16 Oct 2015 14:01:57 -0400 Subject: [PATCH 1/2] METS author limits, date created, and TopicHub as agent This allows setting METS_RESTRICT_MAXIMUM_AUTHORS to an integer. If there are more authors than that number, none are supplied in the METS to prevent triggering a bug in our local DSpace installation. Fixes a bug where we included a title instead of the date. Adds dc.agent as a mechanism for detecting the package came from TopicHub. If a better field is identified, this could be changed and we can work with Carl to update the crosswalk that relies on this value. closes #371 closes #370 closes #375 --- app/models/Item.scala | 20 +++++++++++++++++--- conf/application.conf | 4 ++++ test/unit/ItemSpec.scala | 6 +++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/models/Item.scala b/app/models/Item.scala index b963a33..9bea4fb 100644 --- a/app/models/Item.scala +++ b/app/models/Item.scala @@ -137,7 +137,7 @@ case class Item(id: Int, // DB key } private def metsHdr = { - + TopicHub @@ -158,7 +158,7 @@ case class Item(id: Int, // DB key } - { if( hasMetadata("author") ) + { if( hasMetadata("author") && include_authors) { for ( author <- metadataValues("author") ) yield { author } @@ -166,7 +166,7 @@ case class Item(id: Int, // DB key } } - { if( hasMetadata("additional_author") ) + { if( hasMetadata("additional_author") && include_authors) { for ( author <- metadataValues("additional_author") ) yield { author } @@ -214,6 +214,10 @@ case class Item(id: Int, // DB key } + + TopicHub SCOAP3 + + @@ -252,6 +256,16 @@ case class Item(id: Int, // DB key } + + private def include_authors: Boolean = { + val restrict_at = current.configuration.getInt("mets.restrict_maximum_authors").getOrElse(0) + val author_size = metadataValues("author").size + metadataValues("additional_author").size + if (restrict_at == 0 || author_size < restrict_at) { + true + } else { + false + } + } } object Item { diff --git a/conf/application.conf b/conf/application.conf index 2df0f23..0674d95 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -73,6 +73,10 @@ include "authentication" auth.harvest.key = "" auth.harvest.key = ${?HARVEST_KEY} +# restrict excessive authors in METS? +# to restrict add an Integer to METS_RESTRICT_MAXIMUM_AUTHORS +mets.restrict_maximum_authors = ${?METS_RESTRICT_MAXIMUM_AUTHORS} + # Branding changes should be made using Environment Variables # Developers should access values via the HubUtils model rather than directly. brand.name=${?SITE_NAME} diff --git a/test/unit/ItemSpec.scala b/test/unit/ItemSpec.scala index 9c6dae8..c1b56ca 100644 --- a/test/unit/ItemSpec.scala +++ b/test/unit/ItemSpec.scala @@ -490,11 +490,11 @@ class ItemSpec extends Specification { (mets \\ "dmdSec").size must equalTo(1) (mets \\ "fileSec").size must equalTo(1) (mets \\ "structMap").size must equalTo(1) - (mets \\ "valueString").size must equalTo(3) + (mets \\ "valueString").size must equalTo(4) item.addMetadata("abstract", "More stuff!!!") val mets_abstract = item.toMets - (mets_abstract \\ "valueString").size must equalTo(4) + (mets_abstract \\ "valueString").size must equalTo(5) item.addMetadata("doi", "asdf//popcorn.123.456") item.addMetadata("additional_author", "Anonymoys Coward") @@ -505,7 +505,7 @@ class ItemSpec extends Specification { item.addMetadata("accessUri", "http://example.com/a.pdf?pdfa") item.addMetadata("accessUri", "http://example.com/a.xml") val mets_moar = item.toMets - (mets_moar \\ "valueString").size must equalTo(9) + (mets_moar \\ "valueString").size must equalTo(10) (mets_moar \\ "FLocat").size must equalTo(3) (mets_moar \\ "fptr").size must equalTo(3) } From be01049db109a25a93569df25e114a15b8040f80 Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Mon, 19 Oct 2015 16:17:04 -0400 Subject: [PATCH 2/2] Use dc elements source instead of dc terms agent --- app/models/Item.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/Item.scala b/app/models/Item.scala index 9bea4fb..5896954 100644 --- a/app/models/Item.scala +++ b/app/models/Item.scala @@ -214,7 +214,7 @@ case class Item(id: Int, // DB key } - + TopicHub SCOAP3