Skip to content

Commit

Permalink
Promote to PROD (#313)
Browse files Browse the repository at this point in the history
Features:
* Pivotal ID # 174054535: Disable superUser in request
* Pivotal ID # 174076301: Update pmc api  (#248)
* Pivotal ID # 172817960: Resubmit Notfication (#255)
* Pivotal ID # 169837866: Async File Processing (#256)
* Pivotal ID # 172671360: Warn Users About Upcoming Releases (#268)
* Pivotal ID # 173783625: Partial Updates Timestamp (#269)
* Pivotal ID # 174922363: Add support for previous submission files source
* Pivotal ID # 173908844: Add ext file fields attributes (#260)
* Pivotal ID # 173817309: FIRE Client (#272)
* Pivotal ID # 174746920: Include status fetching submissions (#275)
* Pivotal ID # 171026062: Submission files MD5 Generation (#274)
* Pivotal ID # 175266840: Manual Set AccNo Sequence (#287)
* Pivotal ID # 175101522: File Path Field (#294)
* Pivotal:ID # 175839554 : include user tag as part of extended submission tags (#296)
* Pivotal ID # 175825508: Store submission request - async processing

Bug Fixes:
* Pivotal ID # 173457302: RelPath Calculation (#244)
* Pivotal ID # 173750220: Author TSV Serialization (#245)
* pivotal ID # 174127719: Transaction lock (#250)
* Pivotal ID # 171230259: Draft creation time outs for big submissions (#251)
* Pivotal ID # 174275642: Submission loading strategy (#254)
* Pivotal ID # 174316468: Project Refresh AccNo Template Validation (#257)
* Pivotal ID # 173919045: Restrict Execute Permissions On HTTP Uploaded Files (#265)
* Pivotal ID # 174621725: Wrong Notifications UI URL (#266)
* Pivotal ID # 174697743: Delete draft missing transaction
* Pivotal ID # 174801815: Permissions For Deleted Submissions (#270)
* Pivotal ID # 171026062: FTP Hard Links (#276)
* Pivotal ID # 175357899: Re-submit a submission with rooPath (#279)
* Pivotal ID # 175359447: Async Concurrent Processing Submission (#281)
* Pivotal ID # 175780531: Ext Submission Submitter Validation (#300)
* Pivotal ID # 175632448: Regular User Resubmission (#306)
* Pivotal ID # 176052254: JSON Submission Attributes Validation (#310)
* Pivotal ID # 176052264: Inner Folder Mapping (#311)

Chore Tasks:
* Pivotal ID # 174275207: Test Using The Persistence Layer (#262)
* Pivotal ID # 174947046: ExtSubmission list api (#273)
* Pivotal ID # 174274579: User eager groups (#280)
* Pivotal ID # 175632448: Extra persistence layer interfaces to avoid dependencies on SQL classes (#283)
* Pivotal ID # 175163839: Submission Operations Refactor (#297)
* Pivotal ID # 175926073: Simplify accNoService (#298)
* Pivotal ID # 175163839: Stats Refactor (#299)
  • Loading branch information
jhoanmanuelms authored Dec 10, 2020
1 parent ac70156 commit 31cbec5
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.node.TextNode
import ebi.ac.uk.extended.model.ExtFile
import uk.ac.ebi.extended.serialization.constants.ExtSerializationFields.ATTRIBUTES
import uk.ac.ebi.extended.serialization.constants.ExtSerializationFields.FILE
import uk.ac.ebi.extended.serialization.constants.ExtSerializationFields.FILE_NAME
import uk.ac.ebi.extended.serialization.constants.ExtSerializationFields.FILE_PATH
import uk.ac.ebi.serialization.extensions.convertList
import uk.ac.ebi.serialization.extensions.findNode
import uk.ac.ebi.serialization.extensions.getNode
Expand All @@ -27,8 +27,7 @@ class ExtFileDeserializer : JsonDeserializer<ExtFile>() {

return ExtFile(
file = file,
fileName = node.getNode<TextNode>(FILE_NAME).textValue(),
attributes = mapper.convertList(node.findNode(ATTRIBUTES))
)
fileName = node.getNode<TextNode>(FILE_PATH).textValue(),
attributes = mapper.convertList(node.findNode(ATTRIBUTES)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class EitherExtTypeDeserializerTest(private val tempFolder: TemporaryFolder) {
val json = jsonObj {
"file" to file.absolutePath
"fileName" to "test-file.txt"
"path" to "test-file.txt"
"extType" to "file"
}.toString()

Expand All @@ -80,6 +81,7 @@ class EitherExtTypeDeserializerTest(private val tempFolder: TemporaryFolder) {
"files" to jsonArray(jsonObj {
"file" to file.absolutePath
"fileName" to "test-file-table.txt"
"path" to "test-file-table.txt"
"extType" to "file"
})
"extType" to "filesTable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ExtFileDeserializerTest(private val tempFolder: TemporaryFolder) {
val json = jsonObj {
"file" to file.absolutePath
"fileName" to "test-file.txt"
"path" to "test-file.txt"
"attributes" to jsonArray(jsonObj {
"name" to "Type"
"value" to "Data"
Expand All @@ -38,6 +39,28 @@ class ExtFileDeserializerTest(private val tempFolder: TemporaryFolder) {
assertThat(extFile.attributes.first().value).isEqualTo("Data")
}

@Test
fun `deserialize with inner path`() {
val file = tempFolder.createFile("test-file.txt")
val json = jsonObj {
"file" to file.absolutePath
"fileName" to "test-file.txt"
"path" to "a/b/test-file.txt"
"attributes" to jsonArray(jsonObj {
"name" to "Type"
"value" to "Data"
})
"extType" to "file"
}.toString()

val extFile = testInstance.deserialize<ExtFile>(json)
assertThat(extFile.file).isEqualTo(file)
assertThat(extFile.fileName).isEqualTo("a/b/test-file.txt")
assertThat(extFile.attributes).hasSize(1)
assertThat(extFile.attributes.first().name).isEqualTo("Type")
assertThat(extFile.attributes.first().value).isEqualTo("Data")
}

@Test
fun `invalid file`() {
val json = jsonObj {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ExtFilesTableDeserializerTest(private val tempFolder: TemporaryFolder) {
"files" to jsonArray(jsonObj {
"file" to file.absolutePath
"fileName" to "test-file.txt"
"path" to "test-file.txt"
"attributes" to jsonArray(jsonObj {
"name" to "Type"
"value" to "Data"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ class ExtSectionDeserializerTest(private val tempFolder: TemporaryFolder) {
"type" to "Study"
"fileList" to jsonObj {
"fileName" to "file-list.json"
"path" to "file-list.json"
"files" to jsonArray(jsonObj {
"fileName" to "ref-file.txt"
"path" to "ref-file.txt"
"file" to referencedFile.absolutePath
"extType" to "file"
})
Expand All @@ -68,12 +70,14 @@ class ExtSectionDeserializerTest(private val tempFolder: TemporaryFolder) {
})

"files" to jsonArray(jsonObj {
"fileName" to "section-file.txt"
"fileName" to "section-file-inner-folders.txt"
"path" to "a/b/section-file-inner-folders.txt"
"file" to sectionFile.absolutePath
"extType" to "file"
}, jsonObj {
"files" to jsonArray(jsonObj {
"fileName" to "section-file-table.txt"
"path" to "section-file-table.txt"
"file" to sectionFilesTable.absolutePath
"extType" to "file"
})
Expand Down Expand Up @@ -131,7 +135,7 @@ class ExtSectionDeserializerTest(private val tempFolder: TemporaryFolder) {
assertThat(extFile.isLeft()).isTrue()
extFile.ifLeft {
assertThat(it.file).isEqualTo(sectionFile)
assertThat(it.fileName).isEqualTo("section-file.txt")
assertThat(it.fileName).isEqualTo("a/b/section-file-inner-folders.txt")
}

val extFilesTable = extFiles.second()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inline fun <reified T : JsonNode?> JsonNode.ensureType(node: JsonNode, property:
require(node is T) {
val type = node::class.java.simpleName
val expectedType = T::class.java.simpleName
"Expecting node: '$this', property: '$property' to be of type '$expectedType' but '$type' find instead"
"Expecting node: '$this', property: '$property' to be of type '$expectedType' but '$type' was found instead"
}

return node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ac.uk.ebi.biostd.common.NAME_ATTRIBUTES
import ac.uk.ebi.biostd.common.REFERENCE
import ac.uk.ebi.biostd.common.VALUE
import ac.uk.ebi.biostd.common.VAL_ATTRIBUTES
import ac.uk.ebi.biostd.json.exception.NoAttributeValueException
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonNode
Expand All @@ -20,10 +21,13 @@ internal class AttributeJsonDeserializer : StdDeserializer<Attribute>(Attribute:
override fun deserialize(jp: JsonParser, ctxt: DeserializationContext): Attribute {
val mapper = jp.codec as ObjectMapper
val node: JsonNode = mapper.readTree(jp)
val name = node.getNode<TextNode>(NAME).textValue()
val value = node.getNode<TextNode>(VALUE).textValue()
require(value.isNotBlank()) { throw NoAttributeValueException(name) }

return Attribute(
name = node.getNode<TextNode>(NAME).textValue(),
value = node.getNode<TextNode>(VALUE).textValue(),
name = name,
value = value,
reference = node.get(REFERENCE)?.asBoolean().orFalse(),
valueAttrs = mapper.convertList(node.get(VAL_ATTRIBUTES)),
nameAttrs = mapper.convertList(node.get(NAME_ATTRIBUTES)))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package ac.uk.ebi.biostd.json.exception

class NoAttributeValueException(name: String) : RuntimeException("The value for the attribute '$name' can't be empty")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ac.uk.ebi.biostd.json.deserialization

import ac.uk.ebi.biostd.json.JsonSerializer
import ac.uk.ebi.biostd.json.exception.NoAttributeValueException
import ebi.ac.uk.dsl.json.jsonArray
import ebi.ac.uk.dsl.json.jsonObj
import ebi.ac.uk.model.Attribute
Expand All @@ -14,21 +15,33 @@ class AttributeDeserializerTest {
private val testInstance = JsonSerializer.mapper

@Test
fun `deserialize no value`() {
fun `deserialize empty`() {
val exception = assertThrows<IllegalStateException> { testInstance.deserialize<Attribute>("{}") }

assertThat(exception.message).isEqualTo("Expecting to find property with 'name' in node '{}'")
}

@Test
fun `deserialize no value`() {
val exception = assertThrows<NoAttributeValueException> { testInstance.deserialize<Attribute>("""{
|"name": "attr name",
|"value": ""
|}""".trimMargin()) }

assertThat(exception.message).isEqualTo("The value for the attribute 'attr name' can't be empty")
}

@Test
fun `deserialize with wrong type`() {
val invalidJson = jsonObj {
"name" to jsonArray(1, 2, 3)
}.toString()

val node = "{\"name\":[1,2,3]}"
val exception = assertThrows<IllegalArgumentException> { testInstance.deserialize<Attribute>(invalidJson) }

assertThat(exception.message).isEqualTo(
"Expecting node: '{\"name\":[1,2,3]}', property: 'name' to be of type 'TextNode' but 'ArrayNode' find instead")
"Expecting node: '$node', property: 'name' to be of type 'TextNode' but 'ArrayNode' was found instead")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ class FileDeserializerTest {
"path" to jsonArray(1, 2, 3)
}.toString()

val node = "{\"path\":[1,2,3]}"
val exception = assertThrows<IllegalArgumentException> { testInstance.deserialize<File>(invalidJson) }
assertThat(exception.message).isEqualTo(
"Expecting node: '{\"path\":[1,2,3]}', property: 'path' to be of type 'TextNode' but 'ArrayNode' find instead")
"Expecting node: '$node', property: 'path' to be of type 'TextNode' but 'ArrayNode' was found instead")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ class LinkDeserializerTest {
"url" to jsonArray(1, 2, 3)
}.toString()

val node = "{\"url\":[1,2,3]}"
val exception = assertThrows<IllegalArgumentException> { testInstance.deserialize<Link>(invalidJson) }
assertThat(exception.message).isEqualTo(
"Expecting node: '{\"url\":[1,2,3]}', property: 'url' to be of type 'TextNode' but 'ArrayNode' find instead")
"Expecting node: '$node', property: 'url' to be of type 'TextNode' but 'ArrayNode' was found instead")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class SectionDeserializerTest {
"accno" to jsonArray(1, 2, 3)
}.toString()

val node = "{\"accno\":[1,2,3]}"
val exception = assertThrows<IllegalArgumentException> { testInstance.deserialize<Section>(invalidJson) }
assertThat(exception.message).isEqualTo(
"Expecting node: '{\"accno\":[1,2,3]}', property: 'accno' to be of type 'TextNode' but 'ArrayNode' find instead")
"Expecting node: '$node', property: 'accno' to be of type 'TextNode' but 'ArrayNode' was found instead")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ac.uk.ebi.biostd.persistence.model
import ac.uk.ebi.biostd.persistence.common.model.SubmissionStat
import ac.uk.ebi.biostd.persistence.common.model.SubmissionStatType
import ac.uk.ebi.biostd.persistence.common.model.SubmissionStatType.VIEWS
import com.fasterxml.jackson.annotation.JsonIgnore
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.EnumType
Expand All @@ -26,6 +27,7 @@ class DbSubmissionStat(
) : SubmissionStat {
@Id
@GeneratedValue
@JsonIgnore
var id: Long = 0L

constructor() : this("", -1, VIEWS)
Expand Down

0 comments on commit 31cbec5

Please sign in to comment.