Skip to content

Commit 2b64e59

Browse files
authored
Initial upgrade process support (#4954)
* Initial upgrade process support * Improve test assertions * Fix labels and properties management * Move the data upgrade process to the v2 endpoint and improve references management * Improve test assertions * Add back migration tests
1 parent 08846fc commit 2b64e59

File tree

74 files changed

+1656
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1656
-242
lines changed

app/src/main/java/io/apicurio/registry/ImportLifecycleBean.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import io.apicurio.registry.storage.impexp.EntityInputStream;
99
import io.apicurio.registry.types.Current;
1010
import io.apicurio.registry.utils.impexp.Entity;
11-
import io.apicurio.registry.utils.impexp.EntityReader;
11+
import io.apicurio.registry.utils.impexp.v3.EntityReader;
1212
import jakarta.enterprise.context.ApplicationScoped;
1313
import jakarta.enterprise.event.ObservesAsync;
1414
import jakarta.inject.Inject;

app/src/main/java/io/apicurio/registry/rest/v2/AdminResourceImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import io.apicurio.registry.types.RuleType;
3939
import io.apicurio.registry.types.provider.ArtifactTypeUtilProviderFactory;
4040
import io.apicurio.registry.utils.impexp.Entity;
41-
import io.apicurio.registry.utils.impexp.EntityReader;
41+
import io.apicurio.registry.utils.impexp.v2.EntityReader;
4242
import jakarta.enterprise.context.ApplicationScoped;
4343
import jakarta.inject.Inject;
4444
import jakarta.interceptor.Interceptors;
@@ -264,7 +264,7 @@ public void close() throws IOException {
264264
zip.close();
265265
}
266266
};
267-
this.storage.importData(stream, isNullOrTrue(xRegistryPreserveGlobalId),
267+
this.storage.upgradeData(stream, isNullOrTrue(xRegistryPreserveGlobalId),
268268
isNullOrTrue(xRegistryPreserveContentId));
269269
}
270270

app/src/main/java/io/apicurio/registry/rest/v2/shared/DataExporter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import io.apicurio.registry.storage.RegistryStorage;
44
import io.apicurio.registry.types.Current;
5-
import io.apicurio.registry.utils.impexp.EntityWriter;
5+
import io.apicurio.registry.utils.impexp.v3.EntityWriter;
66
import jakarta.enterprise.context.ApplicationScoped;
77
import jakarta.inject.Inject;
88
import jakarta.ws.rs.core.Response;

app/src/main/java/io/apicurio/registry/rest/v3/AdminResourceImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import io.apicurio.registry.types.RuleType;
4242
import io.apicurio.registry.types.provider.ArtifactTypeUtilProviderFactory;
4343
import io.apicurio.registry.utils.impexp.Entity;
44-
import io.apicurio.registry.utils.impexp.EntityReader;
44+
import io.apicurio.registry.utils.impexp.v3.EntityReader;
4545
import jakarta.enterprise.context.ApplicationScoped;
4646
import jakarta.inject.Inject;
4747
import jakarta.interceptor.Interceptors;

app/src/main/java/io/apicurio/registry/rest/v3/shared/DataExporter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import io.apicurio.registry.storage.RegistryStorage;
44
import io.apicurio.registry.types.Current;
5-
import io.apicurio.registry.utils.impexp.EntityWriter;
5+
import io.apicurio.registry.utils.impexp.v3.EntityWriter;
66
import jakarta.enterprise.context.ApplicationScoped;
77
import jakarta.inject.Inject;
88
import jakarta.ws.rs.core.Response;

app/src/main/java/io/apicurio/registry/storage/RegistryStorage.java

+28-15
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@
4242
import io.apicurio.registry.storage.error.VersionNotFoundException;
4343
import io.apicurio.registry.storage.impexp.EntityInputStream;
4444
import io.apicurio.registry.types.RuleType;
45-
import io.apicurio.registry.utils.impexp.ArtifactEntity;
46-
import io.apicurio.registry.utils.impexp.ArtifactRuleEntity;
47-
import io.apicurio.registry.utils.impexp.ArtifactVersionEntity;
48-
import io.apicurio.registry.utils.impexp.BranchEntity;
49-
import io.apicurio.registry.utils.impexp.CommentEntity;
50-
import io.apicurio.registry.utils.impexp.ContentEntity;
5145
import io.apicurio.registry.utils.impexp.Entity;
52-
import io.apicurio.registry.utils.impexp.GlobalRuleEntity;
53-
import io.apicurio.registry.utils.impexp.GroupEntity;
54-
import io.apicurio.registry.utils.impexp.GroupRuleEntity;
46+
import io.apicurio.registry.utils.impexp.v3.ArtifactEntity;
47+
import io.apicurio.registry.utils.impexp.v3.ArtifactRuleEntity;
48+
import io.apicurio.registry.utils.impexp.v3.ArtifactVersionEntity;
49+
import io.apicurio.registry.utils.impexp.v3.BranchEntity;
50+
import io.apicurio.registry.utils.impexp.v3.CommentEntity;
51+
import io.apicurio.registry.utils.impexp.v3.ContentEntity;
52+
import io.apicurio.registry.utils.impexp.v3.GlobalRuleEntity;
53+
import io.apicurio.registry.utils.impexp.v3.GroupEntity;
54+
import io.apicurio.registry.utils.impexp.v3.GroupRuleEntity;
5555
import org.apache.commons.lang3.tuple.Pair;
5656

5757
import java.time.Instant;
@@ -248,7 +248,7 @@ void updateArtifactMetaData(String groupId, String artifactId, EditableArtifactM
248248

249249
/**
250250
* Get all rules configured for a group.
251-
*
251+
*
252252
* @param groupId
253253
* @throws GroupNotFoundException
254254
* @throws RegistryStorageException
@@ -257,7 +257,7 @@ void updateArtifactMetaData(String groupId, String artifactId, EditableArtifactM
257257

258258
/**
259259
* Create/configure a rule for a group.
260-
*
260+
*
261261
* @param groupId
262262
* @param rule
263263
* @param config
@@ -270,7 +270,7 @@ void createGroupRule(String groupId, RuleType rule, RuleConfigurationDto config)
270270

271271
/**
272272
* Delete all rules configured for a group.
273-
*
273+
*
274274
* @param groupId
275275
* @throws GroupNotFoundException
276276
* @throws RegistryStorageException
@@ -279,7 +279,7 @@ void createGroupRule(String groupId, RuleType rule, RuleConfigurationDto config)
279279

280280
/**
281281
* Update the configuration for a specific rule in a group.
282-
*
282+
*
283283
* @param groupId
284284
* @param rule
285285
* @param config
@@ -292,7 +292,7 @@ void updateGroupRule(String groupId, RuleType rule, RuleConfigurationDto config)
292292

293293
/**
294294
* Delete (unconfigure) a single rule for a group.
295-
*
295+
*
296296
* @param groupId
297297
* @param rule
298298
* @throws GroupNotFoundException
@@ -304,7 +304,7 @@ void deleteGroupRule(String groupId, RuleType rule)
304304

305305
/**
306306
* Gets the current configuration of a single rule in the group.
307-
*
307+
*
308308
* @param groupId
309309
* @param rule
310310
* @throws GroupNotFoundException
@@ -625,6 +625,19 @@ void updateGlobalRule(RuleType rule, RuleConfigurationDto config)
625625
void importData(EntityInputStream entities, boolean preserveGlobalId, boolean preserveContentId)
626626
throws RegistryStorageException;
627627

628+
/**
629+
* Called to upgrade and import previously exported data into the registry. It upgrades the data structure
630+
* from v2 to v3 and imports the data into Registry.
631+
*
632+
* @param entities
633+
* @param preserveGlobalId Preserve global ids. If false, global ids will be set to next id in global id
634+
* sequence.
635+
* @param preserveContentId Preserve content id. If false, content ids will be set to the next ids in the
636+
* content id sequence. Content-Version mapping will be preserved.
637+
* @throws RegistryStorageException
638+
*/
639+
void upgradeData(EntityInputStream entities, boolean preserveGlobalId, boolean preserveContentId);
640+
628641
/**
629642
* Counts the total number of artifacts in the registry.
630643
*

app/src/main/java/io/apicurio/registry/storage/decorator/ReadOnlyRegistryStorageDecorator.java

+16-9
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
import io.apicurio.registry.storage.error.RuleNotFoundException;
2929
import io.apicurio.registry.storage.impexp.EntityInputStream;
3030
import io.apicurio.registry.types.RuleType;
31-
import io.apicurio.registry.utils.impexp.ArtifactEntity;
32-
import io.apicurio.registry.utils.impexp.ArtifactRuleEntity;
33-
import io.apicurio.registry.utils.impexp.ArtifactVersionEntity;
34-
import io.apicurio.registry.utils.impexp.BranchEntity;
35-
import io.apicurio.registry.utils.impexp.CommentEntity;
36-
import io.apicurio.registry.utils.impexp.ContentEntity;
37-
import io.apicurio.registry.utils.impexp.GlobalRuleEntity;
38-
import io.apicurio.registry.utils.impexp.GroupEntity;
39-
import io.apicurio.registry.utils.impexp.GroupRuleEntity;
31+
import io.apicurio.registry.utils.impexp.v3.ArtifactEntity;
32+
import io.apicurio.registry.utils.impexp.v3.ArtifactRuleEntity;
33+
import io.apicurio.registry.utils.impexp.v3.ArtifactVersionEntity;
34+
import io.apicurio.registry.utils.impexp.v3.BranchEntity;
35+
import io.apicurio.registry.utils.impexp.v3.CommentEntity;
36+
import io.apicurio.registry.utils.impexp.v3.ContentEntity;
37+
import io.apicurio.registry.utils.impexp.v3.GlobalRuleEntity;
38+
import io.apicurio.registry.utils.impexp.v3.GroupEntity;
39+
import io.apicurio.registry.utils.impexp.v3.GroupRuleEntity;
4040
import jakarta.enterprise.context.ApplicationScoped;
4141
import org.apache.commons.lang3.tuple.Pair;
4242
import org.eclipse.microprofile.config.inject.ConfigProperty;
@@ -244,6 +244,13 @@ public void importData(EntityInputStream entities, boolean preserveGlobalId, boo
244244
delegate.importData(entities, preserveGlobalId, preserveContentId);
245245
}
246246

247+
@Override
248+
public void upgradeData(EntityInputStream entities, boolean preserveGlobalId, boolean preserveContentId)
249+
throws RegistryStorageException {
250+
checkReadOnly();
251+
delegate.upgradeData(entities, preserveGlobalId, preserveContentId);
252+
}
253+
247254
@Override
248255
public void createRoleMapping(String principalId, String role, String principalName)
249256
throws RegistryStorageException {

app/src/main/java/io/apicurio/registry/storage/decorator/RegistryStorageDecoratorBase.java

+15-9
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
import io.apicurio.registry.storage.error.VersionNotFoundException;
2626
import io.apicurio.registry.storage.impexp.EntityInputStream;
2727
import io.apicurio.registry.types.RuleType;
28-
import io.apicurio.registry.utils.impexp.ArtifactEntity;
29-
import io.apicurio.registry.utils.impexp.ArtifactRuleEntity;
30-
import io.apicurio.registry.utils.impexp.ArtifactVersionEntity;
31-
import io.apicurio.registry.utils.impexp.BranchEntity;
32-
import io.apicurio.registry.utils.impexp.CommentEntity;
33-
import io.apicurio.registry.utils.impexp.ContentEntity;
34-
import io.apicurio.registry.utils.impexp.GlobalRuleEntity;
35-
import io.apicurio.registry.utils.impexp.GroupEntity;
36-
import io.apicurio.registry.utils.impexp.GroupRuleEntity;
28+
import io.apicurio.registry.utils.impexp.v3.ArtifactEntity;
29+
import io.apicurio.registry.utils.impexp.v3.ArtifactRuleEntity;
30+
import io.apicurio.registry.utils.impexp.v3.ArtifactVersionEntity;
31+
import io.apicurio.registry.utils.impexp.v3.BranchEntity;
32+
import io.apicurio.registry.utils.impexp.v3.CommentEntity;
33+
import io.apicurio.registry.utils.impexp.v3.ContentEntity;
34+
import io.apicurio.registry.utils.impexp.v3.GlobalRuleEntity;
35+
import io.apicurio.registry.utils.impexp.v3.GroupEntity;
36+
import io.apicurio.registry.utils.impexp.v3.GroupRuleEntity;
3737
import org.apache.commons.lang3.tuple.Pair;
3838

3939
import java.util.List;
@@ -187,6 +187,12 @@ public void importData(EntityInputStream entities, boolean preserveGlobalId, boo
187187
delegate.importData(entities, preserveGlobalId, preserveContentId);
188188
}
189189

190+
@Override
191+
public void upgradeData(EntityInputStream entities, boolean preserveGlobalId, boolean preserveContentId)
192+
throws RegistryStorageException {
193+
delegate.upgradeData(entities, preserveGlobalId, preserveContentId);
194+
}
195+
190196
@Override
191197
public void createRoleMapping(String principalId, String role, String principalName)
192198
throws RegistryStorageException {

app/src/main/java/io/apicurio/registry/storage/impl/gitops/AbstractReadOnlyRegistryStorage.java

+15-9
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
import io.apicurio.registry.storage.error.RegistryStorageException;
2222
import io.apicurio.registry.storage.impexp.EntityInputStream;
2323
import io.apicurio.registry.types.RuleType;
24-
import io.apicurio.registry.utils.impexp.ArtifactEntity;
25-
import io.apicurio.registry.utils.impexp.ArtifactRuleEntity;
26-
import io.apicurio.registry.utils.impexp.ArtifactVersionEntity;
27-
import io.apicurio.registry.utils.impexp.BranchEntity;
28-
import io.apicurio.registry.utils.impexp.CommentEntity;
29-
import io.apicurio.registry.utils.impexp.ContentEntity;
30-
import io.apicurio.registry.utils.impexp.GlobalRuleEntity;
31-
import io.apicurio.registry.utils.impexp.GroupEntity;
32-
import io.apicurio.registry.utils.impexp.GroupRuleEntity;
24+
import io.apicurio.registry.utils.impexp.v3.ArtifactEntity;
25+
import io.apicurio.registry.utils.impexp.v3.ArtifactRuleEntity;
26+
import io.apicurio.registry.utils.impexp.v3.ArtifactVersionEntity;
27+
import io.apicurio.registry.utils.impexp.v3.BranchEntity;
28+
import io.apicurio.registry.utils.impexp.v3.CommentEntity;
29+
import io.apicurio.registry.utils.impexp.v3.ContentEntity;
30+
import io.apicurio.registry.utils.impexp.v3.GlobalRuleEntity;
31+
import io.apicurio.registry.utils.impexp.v3.GroupEntity;
32+
import io.apicurio.registry.utils.impexp.v3.GroupRuleEntity;
3333
import org.apache.commons.lang3.tuple.Pair;
3434

3535
import java.util.List;
@@ -179,6 +179,12 @@ public void importData(EntityInputStream entities, boolean preserveGlobalId, boo
179179
readOnlyViolation();
180180
}
181181

182+
@Override
183+
public void upgradeData(EntityInputStream entities, boolean preserveGlobalId, boolean preserveContentId)
184+
throws RegistryStorageException {
185+
readOnlyViolation();
186+
}
187+
182188
@Override
183189
public void createRoleMapping(String principalId, String role, String principalName)
184190
throws RegistryStorageException {

app/src/main/java/io/apicurio/registry/storage/impl/gitops/GitManager.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
import io.apicurio.registry.types.ContentTypes;
1717
import io.apicurio.registry.types.RuleType;
1818
import io.apicurio.registry.types.VersionState;
19-
import io.apicurio.registry.utils.impexp.ArtifactEntity;
20-
import io.apicurio.registry.utils.impexp.ArtifactRuleEntity;
21-
import io.apicurio.registry.utils.impexp.ArtifactVersionEntity;
22-
import io.apicurio.registry.utils.impexp.ContentEntity;
23-
import io.apicurio.registry.utils.impexp.GlobalRuleEntity;
24-
import io.apicurio.registry.utils.impexp.GroupEntity;
19+
import io.apicurio.registry.utils.impexp.v3.ArtifactEntity;
20+
import io.apicurio.registry.utils.impexp.v3.ArtifactRuleEntity;
21+
import io.apicurio.registry.utils.impexp.v3.ArtifactVersionEntity;
22+
import io.apicurio.registry.utils.impexp.v3.ContentEntity;
23+
import io.apicurio.registry.utils.impexp.v3.GlobalRuleEntity;
24+
import io.apicurio.registry.utils.impexp.v3.GroupEntity;
2525
import jakarta.annotation.PreDestroy;
2626
import jakarta.enterprise.context.ApplicationScoped;
2727
import jakarta.inject.Inject;

0 commit comments

Comments
 (0)