diff --git a/app/models/Item.scala b/app/models/Item.scala index b963a33..5896954 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) }