Skip to content

Commit 8468ab1

Browse files
committed
var/val fix
1 parent c1bd2af commit 8468ab1

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

app/api/Datasets.scala

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,6 +2219,7 @@ class Datasets @Inject()(
22192219

22202220
if (level == "file" || level == "dataset")
22212221
totalBytes += bytesRead
2222+
22222223
byteArrayOutputStream.reset()
22232224
Future.successful(chunk)
22242225
}
@@ -2326,20 +2327,17 @@ class Datasets @Inject()(
23262327
s += "Payload-Oxum: " + totalbytes + "." + totalFiles + "\n"
23272328
s += "Internal-Sender-Identifier: " + dataset.id + "\n"
23282329
s += "Internal-Sender-Description: " + dataset.description + "\n"
2329-
contact match {
2330-
case Some(u) => {
2331-
s += "Contact-Name: " + user.get.fullName + "\n"
2332-
s += "Contact-Email: " + user.get.email.getOrElse("") + "\n"
2333-
}
2334-
case None => {}
2330+
if (contact.isDefined) {
2331+
s += "Contact-Name: " + contact.get.fullName + "\n"
2332+
s += "Contact-Email: " + contact.get.email.getOrElse("") + "\n"
23352333
}
23362334
Some(new ByteArrayInputStream(s.getBytes("UTF-8")))
23372335
}
23382336

23392337
// BagIt version & encoding
23402338
private def addBagInfoToZip(zip : ZipOutputStream) : Option[InputStream] = {
23412339
zip.putNextEntry(new ZipEntry("bag-info.txt"))
2342-
val s = ""
2340+
var s = ""
23432341
s += "BagIt-Version: 0.97\n"
23442342
s += "Tag-File-Character-Encoding: UTF-8\n"
23452343
Some(new ByteArrayInputStream(s.getBytes("UTF-8")))
@@ -2360,9 +2358,26 @@ class Datasets @Inject()(
23602358

23612359
private def addDataCiteMetadataToZip(zip: ZipOutputStream): Option[InputStream] = {
23622360
zip.putNextEntry(new ZipEntry("metadata/datacite.xml"))
2363-
var s = ""
2364-
s += "<resource xsi:schemaLocation=\"http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4/metadata.xsd\">\n"
2365-
2361+
val nodata = "None"
2362+
var s = "<resource xsi:schemaLocation=\"http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4/metadata.xsd\">\n"
2363+
2364+
// Creators
2365+
s += "<creators>\n"
2366+
s += "\t<creator>\n"
2367+
s += "\t\t<creatorName>"+nodata+"</creatorName>\n"
2368+
s += "\t\t<nameIdentifier>"+nodata+"</nameIdentifier>\n"
2369+
s += "\t\t<nameIdentifierScheme>ORCID</nameIdentifierScheme>\n"
2370+
s += "\t</creator>\n"
2371+
s += "</creators>\n"
2372+
// Title
2373+
s += "<titles>\n\t<title>"+nodata+"</title>\n</titles>\n"
2374+
// Publisher (required?)
2375+
s += "<publisher>Clowder</publisher>\n"
2376+
// Year
2377+
s += "<publicationYear>"+nodata+"</publicationYear>\n"
2378+
// Description
2379+
s += "<descriptions>\n\t<description>"+nodata+"</description>\n</descriptions>\n"
2380+
s += "</resource>"
23662381

23672382
Some(new ByteArrayInputStream(s.getBytes("UTF-8")))
23682383
}

0 commit comments

Comments
 (0)