CORDA-2490 Attachment in the directory fails to correctly upload (#4627) (#4629)

The column 'uploader' was marked as not updatable entity so any update wasn't propagated to the database when the attachment was uploaded again and the uploader field was changed to a trusted one. Also 'saveOrUpdate' removed, the entity is already managed, saveOrUpdate is for detached/new entity.

(cherry picked from commit 9f4c8bcea5)
This commit is contained in:
szymonsztuka 2019-01-24 10:23:26 +00:00 committed by josecoll
parent 2bc1e73833
commit 3384470f6b

View File

@ -96,7 +96,7 @@ class NodeAttachmentService(
@Column(name = "insertion_date", nullable = false, updatable = false) @Column(name = "insertion_date", nullable = false, updatable = false)
var insertionDate: Instant = Instant.now(), var insertionDate: Instant = Instant.now(),
@Column(name = "uploader", updatable = false, nullable = true) @Column(name = "uploader", nullable = true)
var uploader: String? = null, var uploader: String? = null,
@Column(name = "filename", updatable = false, nullable = true) @Column(name = "filename", updatable = false, nullable = true)
@ -381,7 +381,6 @@ class NodeAttachmentService(
if (attachment.uploader != uploader) { if (attachment.uploader != uploader) {
verifyVersionUniquenessForSignedAttachments(contractClassNames, attachment.version, attachment.signers) verifyVersionUniquenessForSignedAttachments(contractClassNames, attachment.version, attachment.signers)
attachment.uploader = uploader attachment.uploader = uploader
session.saveOrUpdate(attachment)
log.info("Updated attachment $id with uploader $uploader") log.info("Updated attachment $id with uploader $uploader")
contractClassNames.forEach { contractsCache.invalidate(it) } contractClassNames.forEach { contractsCache.invalidate(it) }
loadAttachmentContent(id)?.let { attachmentAndContent -> loadAttachmentContent(id)?.let { attachmentAndContent ->