mirror of
https://github.com/corda/corda.git
synced 2025-01-14 00:39:57 +00:00
Finished porting change to make JPA entities non-final and serializable.
This commit is contained in:
parent
bc3605e8da
commit
b93f12d413
@ -1,6 +1,7 @@
|
||||
package com.r3.corda.networkmanage.common.persistence.entity
|
||||
|
||||
import com.r3.corda.networkmanage.common.persistence.CrlIssuer
|
||||
import java.io.Serializable
|
||||
import java.security.cert.X509CRL
|
||||
import java.time.Instant
|
||||
import javax.persistence.*
|
||||
@ -26,4 +27,4 @@ class CertificateRevocationListEntity(
|
||||
|
||||
@Column(name = "modified_at", nullable = false)
|
||||
val modifiedAt: Instant = Instant.now()
|
||||
)
|
||||
) : Serializable
|
@ -3,6 +3,7 @@ package com.r3.corda.networkmanage.common.persistence.entity
|
||||
import com.r3.corda.networkmanage.common.persistence.RequestStatus
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import org.hibernate.envers.Audited
|
||||
import java.io.Serializable
|
||||
import java.math.BigInteger
|
||||
import java.security.cert.CRLReason
|
||||
import java.time.Instant
|
||||
@ -57,4 +58,4 @@ data class CertificateRevocationRequestEntity(
|
||||
@Audited
|
||||
@Column(name = "remark", length = 256)
|
||||
val remark: String? = null
|
||||
)
|
||||
) : Serializable
|
@ -19,6 +19,7 @@ import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.nodeapi.internal.crypto.x509Certificates
|
||||
import org.bouncycastle.pkcs.PKCS10CertificationRequest
|
||||
import org.hibernate.envers.Audited
|
||||
import java.io.Serializable
|
||||
import java.math.BigInteger
|
||||
import java.security.cert.CertPath
|
||||
import java.time.Instant
|
||||
@ -69,7 +70,7 @@ data class CertificateSigningRequestEntity(
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "private_network", foreignKey = ForeignKey(name = "FK__CSR__PN"))
|
||||
val privateNetwork: PrivateNetworkEntity? = null
|
||||
) {
|
||||
) : Serializable {
|
||||
fun toCertificateSigningRequest(): CertificateSigningRequest {
|
||||
return CertificateSigningRequest(
|
||||
requestId = requestId,
|
||||
@ -108,7 +109,7 @@ data class CertificateDataEntity(
|
||||
|
||||
@Column(name = "cert_serial_number", unique = true, nullable = false, columnDefinition = "NUMERIC(28)")
|
||||
val certificateSerialNumber: BigInteger
|
||||
) {
|
||||
) : Serializable {
|
||||
fun toCertificateData(): CertificateData = CertificateData(certificateStatus, certPath)
|
||||
|
||||
val legalName: CordaX500Name get() {
|
||||
@ -125,4 +126,4 @@ data class PrivateNetworkEntity(
|
||||
|
||||
@Column(name = "name", length = 255, nullable = false)
|
||||
val networkName: String
|
||||
)
|
||||
) : Serializable
|
@ -14,6 +14,7 @@ import net.corda.core.internal.DigitalSignatureWithCert
|
||||
import net.corda.core.serialization.serialize
|
||||
import net.corda.nodeapi.internal.network.NetworkMap
|
||||
import net.corda.nodeapi.internal.network.SignedNetworkMap
|
||||
import java.io.Serializable
|
||||
import java.security.cert.X509Certificate
|
||||
import javax.persistence.*
|
||||
|
||||
@ -41,7 +42,7 @@ class NetworkMapEntity(
|
||||
@ManyToOne(optional = false, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "network_parameters", nullable = false)
|
||||
val networkParameters: NetworkParametersEntity
|
||||
) {
|
||||
) : Serializable {
|
||||
fun toSignedNetworkMap(): SignedNetworkMap {
|
||||
return SignedNetworkMap(networkMap.serialize(), DigitalSignatureWithCert(certificate, signature))
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import net.corda.core.internal.DigitalSignatureWithCert
|
||||
import net.corda.core.node.NetworkParameters
|
||||
import net.corda.core.serialization.serialize
|
||||
import net.corda.nodeapi.internal.network.SignedNetworkParameters
|
||||
import java.io.Serializable
|
||||
import java.security.cert.X509Certificate
|
||||
import java.time.Instant
|
||||
import javax.persistence.*
|
||||
@ -43,12 +44,13 @@ class NetworkParametersEntity(
|
||||
@Column(name = "cert")
|
||||
@Convert(converter = X509CertificateConverter::class)
|
||||
val certificate: X509Certificate?
|
||||
) {
|
||||
) : Serializable {
|
||||
val isSigned: Boolean get() = certificate != null && signature != null
|
||||
|
||||
fun toSignedNetworkParameters(): SignedNetworkParameters {
|
||||
if (certificate == null || signature == null) throw IllegalStateException("Network parameters entity is not signed: $hash")
|
||||
return SignedNetworkParameters(networkParameters.serialize(), DigitalSignatureWithCert(certificate, signature))
|
||||
val cert = certificate ?: throw IllegalStateException("Network parameters entity is not signed: $hash")
|
||||
val sign = signature ?: throw IllegalStateException("Network parameters entity is not signed: $hash")
|
||||
return SignedNetworkParameters(networkParameters.serialize(), DigitalSignatureWithCert(cert, sign))
|
||||
}
|
||||
|
||||
fun copy(parametersHash: String = this.hash,
|
||||
|
@ -11,6 +11,7 @@
|
||||
package com.r3.corda.networkmanage.common.persistence.entity
|
||||
|
||||
import net.corda.nodeapi.internal.SignedNodeInfo
|
||||
import java.io.Serializable
|
||||
import java.time.Instant
|
||||
import javax.persistence.*
|
||||
|
||||
@ -40,7 +41,7 @@ data class NodeInfoEntity(
|
||||
@Column(name = "published_at", nullable = false)
|
||||
val publishedAt: Instant = Instant.now(),
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "accepted_params_update")
|
||||
val acceptedParametersUpdate: ParametersUpdateEntity?
|
||||
)
|
||||
) : Serializable
|
||||
|
@ -2,6 +2,7 @@ package com.r3.corda.networkmanage.common.persistence.entity
|
||||
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.nodeapi.internal.network.ParametersUpdate
|
||||
import java.io.Serializable
|
||||
import java.time.Instant
|
||||
import javax.persistence.*
|
||||
|
||||
@ -26,7 +27,7 @@ data class ParametersUpdateEntity(
|
||||
@Column(name = "status", length = 16, nullable = false, columnDefinition = "NVARCHAR(16)")
|
||||
@Enumerated(EnumType.STRING)
|
||||
val status: UpdateStatus = UpdateStatus.NEW
|
||||
) {
|
||||
) : Serializable {
|
||||
fun toParametersUpdate(): ParametersUpdate {
|
||||
return ParametersUpdate(SecureHash.parse(networkParameters.hash), description, updateDeadline)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.corda.node.utilities.AffinityExecutor
|
||||
import net.corda.nodeapi.internal.persistence.CordaPersistence
|
||||
import net.corda.nodeapi.internal.persistence.NODE_DATABASE_PREFIX
|
||||
import org.hibernate.Session
|
||||
import java.io.Serializable
|
||||
import java.time.Duration
|
||||
import java.time.LocalDateTime
|
||||
import java.time.temporal.ChronoField
|
||||
@ -57,7 +58,7 @@ class RunOnceService(private val database: CordaPersistence, private val machine
|
||||
|
||||
@Entity
|
||||
@Table(name = TABLE)
|
||||
class MutualExclusion(machineNameInit: String, pidInit: String, timeStampInit: LocalDateTime, versionInit: Long = 0) {
|
||||
class MutualExclusion(machineNameInit: String, pidInit: String, timeStampInit: LocalDateTime, versionInit: Long = 0) : Serializable {
|
||||
@Column(name = ID, insertable = false, updatable = false)
|
||||
@Id
|
||||
val id: Char = 'X'
|
||||
|
@ -155,7 +155,7 @@ object TestSchema : MappedSchema(SchemaFamily::class.java, 1, setOf(Parent::clas
|
||||
@Suppress("unused")
|
||||
@Entity
|
||||
@Table(name = "children")
|
||||
class Child {
|
||||
class Child : Serializable {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "child_id", unique = true, nullable = false)
|
||||
|
Loading…
Reference in New Issue
Block a user