31
31
import io .apicurio .registry .types .provider .DefaultArtifactTypeUtilProviderImpl ;
32
32
import io .apicurio .registry .utils .impexp .ContentEntity ;
33
33
import jakarta .enterprise .context .ApplicationScoped ;
34
+ import jakarta .enterprise .context .control .ActivateRequestContext ;
34
35
import jakarta .inject .Inject ;
35
36
import org .apache .commons .codec .digest .DigestUtils ;
36
37
import org .slf4j .Logger ;
@@ -63,6 +64,8 @@ public void upgrade(Handle dbHandle) throws Exception {
63
64
64
65
@ Override
65
66
public void upgrade (RegistryStorage registryStorage , Handle dbHandle ) throws Exception {
67
+ this .storage = registryStorage ;
68
+
66
69
String sql = "SELECT c.contentId, c.content, c.canonicalHash, c.contentHash, c.artifactreferences, v.tenantId "
67
70
+ "FROM versions v "
68
71
+ "JOIN content c on c.contentId = v.contentId "
@@ -79,15 +82,20 @@ public void upgrade(RegistryStorage registryStorage, Handle dbHandle) throws Exc
79
82
}
80
83
}
81
84
85
+ @ ActivateRequestContext
82
86
protected void updateCanonicalHash (TenantContentEntity contentEntity ) {
83
87
try {
84
88
85
89
String canonicalContentHash ;
90
+ byte [] contentBytes = this .canonicalizeContent (contentEntity .contentEntity , ArtifactType .AVRO ).bytes ();
91
+
92
+ logger .debug ("Processing content {}" , contentEntity .toString ());
93
+
86
94
if (contentEntity .contentEntity .serializedReferences != null ) {
87
95
byte [] referencesBytes = contentEntity .contentEntity .serializedReferences .getBytes (StandardCharsets .UTF_8 );
88
- canonicalContentHash = DigestUtils .sha256Hex (concatContentAndReferences (this . canonicalizeContent ( contentEntity . contentEntity , ArtifactType . AVRO ). bytes () , referencesBytes ));
96
+ canonicalContentHash = DigestUtils .sha256Hex (concatContentAndReferences (contentBytes , referencesBytes ));
89
97
} else {
90
- canonicalContentHash = DigestUtils .sha256Hex (this . canonicalizeContent ( contentEntity . contentEntity , contentEntity . contentEntity . artifactType ). bytes () );
98
+ canonicalContentHash = DigestUtils .sha256Hex (contentBytes );
91
99
}
92
100
93
101
if (canonicalContentHash .equals (contentEntity .contentEntity .canonicalHash )) {
0 commit comments