1
1
package io .apicurio .registry .rest .v2 ;
2
2
3
- import io .apicurio .common .apps .config .Dynamic ;
4
3
import io .apicurio .common .apps .config .DynamicConfigPropertyDef ;
5
4
import io .apicurio .common .apps .config .DynamicConfigPropertyDto ;
6
5
import io .apicurio .common .apps .config .DynamicConfigPropertyIndex ;
7
- import io .apicurio .common .apps .config .Info ;
8
6
import io .apicurio .common .apps .logging .Logged ;
9
7
import io .apicurio .common .apps .logging .audit .Audited ;
10
8
import io .apicurio .registry .auth .Authorized ;
16
14
import io .apicurio .registry .rest .MissingRequiredParameterException ;
17
15
import io .apicurio .registry .rest .v2 .beans .ArtifactTypeInfo ;
18
16
import io .apicurio .registry .rest .v2 .beans .ConfigurationProperty ;
19
- import io .apicurio .registry .rest .v2 .beans .DownloadRef ;
20
17
import io .apicurio .registry .rest .v2 .beans .RoleMapping ;
21
18
import io .apicurio .registry .rest .v2 .beans .Rule ;
22
19
import io .apicurio .registry .rest .v2 .beans .UpdateConfigurationProperty ;
23
20
import io .apicurio .registry .rest .v2 .beans .UpdateRole ;
24
- import io .apicurio .registry .rest .v2 .shared .DataExporter ;
25
21
import io .apicurio .registry .rules .DefaultRuleDeletionException ;
26
22
import io .apicurio .registry .rules .RulesProperties ;
27
23
import io .apicurio .registry .storage .RegistryStorage ;
28
- import io .apicurio .registry .storage .dto .DownloadContextDto ;
29
- import io .apicurio .registry .storage .dto .DownloadContextType ;
30
24
import io .apicurio .registry .storage .dto .RoleMappingDto ;
31
25
import io .apicurio .registry .storage .dto .RuleConfigurationDto ;
32
26
import io .apicurio .registry .storage .error .ConfigPropertyNotFoundException ;
33
27
import io .apicurio .registry .storage .error .InvalidPropertyValueException ;
34
28
import io .apicurio .registry .storage .error .RuleNotFoundException ;
35
- import io .apicurio .registry .storage .impexp . EntityInputStream ;
29
+ import io .apicurio .registry .storage .importing . ImportExportConfigProperties ;
36
30
import io .apicurio .registry .types .Current ;
37
31
import io .apicurio .registry .types .RoleType ;
38
32
import io .apicurio .registry .types .RuleType ;
39
33
import io .apicurio .registry .types .provider .ArtifactTypeUtilProviderFactory ;
40
- import io .apicurio .registry .utils .impexp .Entity ;
41
- import io .apicurio .registry .utils .impexp .v2 .EntityReader ;
42
34
import jakarta .enterprise .context .ApplicationScoped ;
43
35
import jakarta .inject .Inject ;
44
36
import jakarta .interceptor .Interceptors ;
45
- import jakarta .servlet .http .HttpServletRequest ;
46
- import jakarta .ws .rs .core .Context ;
47
- import jakarta .ws .rs .core .MediaType ;
48
37
import jakarta .ws .rs .core .Response ;
49
38
import org .eclipse .microprofile .config .Config ;
50
- import org .eclipse .microprofile .config .inject .ConfigProperty ;
51
39
import org .slf4j .Logger ;
52
40
53
- import java .io .IOException ;
54
41
import java .io .InputStream ;
55
- import java .nio .charset .StandardCharsets ;
56
42
import java .util .HashMap ;
57
43
import java .util .List ;
58
44
import java .util .Map ;
59
45
import java .util .Set ;
60
- import java .util .function .Supplier ;
61
46
import java .util .stream .Collectors ;
62
47
import java .util .stream .Stream ;
63
- import java .util .zip .ZipInputStream ;
64
48
65
49
import static io .apicurio .common .apps .logging .audit .AuditingConstants .KEY_FOR_BROWSER ;
66
50
import static io .apicurio .common .apps .logging .audit .AuditingConstants .KEY_NAME ;
@@ -97,17 +81,12 @@ public class AdminResourceImpl implements AdminResource {
97
81
Config config ;
98
82
99
83
@ Inject
100
- DataExporter exporter ;
84
+ ImportExportConfigProperties importExportProps ;
101
85
102
- @ Context
103
- HttpServletRequest request ;
104
-
105
- @ Dynamic (label = "Download link expiry" , description = "The number of seconds that a generated link to a .zip download file is active before expiring." )
106
- @ ConfigProperty (name = "apicurio.download.href.ttl.seconds" , defaultValue = "30" )
107
- @ Info (category = "download" , description = "Download link expiry" , availableSince = "2.1.2.Final" )
108
- Supplier <Long > downloadHrefTtl ;
86
+ @ Inject
87
+ io .apicurio .registry .rest .v3 .AdminResourceImpl v3Admin ;
109
88
110
- private static final void requireParameter (String parameterName , Object parameterValue ) {
89
+ private static void requireParameter (String parameterName , Object parameterValue ) {
111
90
if (parameterValue == null ) {
112
91
throw new MissingRequiredParameterException (parameterName );
113
92
}
@@ -124,7 +103,6 @@ public List<ArtifactTypeInfo> listArtifactTypes() {
124
103
ati .setName (t );
125
104
return ati ;
126
105
}).collect (Collectors .toList ());
127
-
128
106
}
129
107
130
108
/**
@@ -246,26 +224,7 @@ public void deleteGlobalRule(RuleType rule) {
246
224
@ Authorized (style = AuthorizedStyle .None , level = AuthorizedLevel .Admin )
247
225
public void importData (Boolean xRegistryPreserveGlobalId , Boolean xRegistryPreserveContentId ,
248
226
InputStream data ) {
249
- final ZipInputStream zip = new ZipInputStream (data , StandardCharsets .UTF_8 );
250
- final EntityReader reader = new EntityReader (zip );
251
- EntityInputStream stream = new EntityInputStream () {
252
- @ Override
253
- public Entity nextEntity () throws IOException {
254
- try {
255
- return reader .readEntity ();
256
- } catch (Exception e ) {
257
- log .error ("Error reading data from import ZIP file." , e );
258
- return null ;
259
- }
260
- }
261
-
262
- @ Override
263
- public void close () throws IOException {
264
- zip .close ();
265
- }
266
- };
267
- this .storage .upgradeData (stream , isNullOrTrue (xRegistryPreserveGlobalId ),
268
- isNullOrTrue (xRegistryPreserveContentId ));
227
+ v3Admin .importData (xRegistryPreserveGlobalId , xRegistryPreserveContentId , false , data );
269
228
}
270
229
271
230
/**
@@ -275,20 +234,8 @@ public void close() throws IOException {
275
234
@ Audited (extractParameters = { "0" , KEY_FOR_BROWSER })
276
235
@ Authorized (style = AuthorizedStyle .None , level = AuthorizedLevel .Admin )
277
236
public Response exportData (Boolean forBrowser ) {
278
- String acceptHeader = request .getHeader ("Accept" );
279
- if (Boolean .TRUE .equals (forBrowser ) || MediaType .APPLICATION_JSON .equals (acceptHeader )) {
280
- long expires = System .currentTimeMillis () + (downloadHrefTtl .get () * 1000 );
281
- DownloadContextDto downloadCtx = DownloadContextDto .builder ().type (DownloadContextType .EXPORT )
282
- .expires (expires ).build ();
283
- String downloadId = storage .createDownload (downloadCtx );
284
- String downloadHref = createDownloadHref (downloadId );
285
- DownloadRef downloadRef = new DownloadRef ();
286
- downloadRef .setDownloadId (downloadId );
287
- downloadRef .setHref (downloadHref );
288
- return Response .ok (downloadRef ).type (MediaType .APPLICATION_JSON_TYPE ).build ();
289
- } else {
290
- return exporter .exportData ();
291
- }
237
+ throw new UnsupportedOperationException (
238
+ "Exporting data using the Registry Core v2 API is no longer supported. Use the v3 API." );
292
239
}
293
240
294
241
/**
@@ -463,7 +410,7 @@ private ConfigurationProperty defToConfigurationProperty(DynamicConfigPropertyDe
463
410
464
411
/**
465
412
* Lookup the dynamic configuration property being set. Ensure that it exists (throws a
466
- * {@link NotFoundException} if it does not.
413
+ * {@link io.apicurio.registry.storage.error. NotFoundException} if it does not.
467
414
*
468
415
* @param propertyName the name of the dynamic property
469
416
* @return the dynamic config property definition
0 commit comments