-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the new resolve mechanism only for json
- Loading branch information
1 parent
de5de53
commit 58635f2
Showing
3 changed files
with
35 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import io.apicurio.registry.storage.impl.sql.RegistryContentUtils; | ||
import io.apicurio.registry.types.ArtifactMediaTypes; | ||
import io.apicurio.registry.types.ArtifactState; | ||
import io.apicurio.registry.types.ArtifactType; | ||
import io.apicurio.registry.types.Current; | ||
import io.apicurio.registry.types.ReferenceType; | ||
import io.apicurio.registry.types.provider.ArtifactTypeUtilProvider; | ||
|
@@ -53,7 +54,7 @@ | |
* @author [email protected] | ||
*/ | ||
@ApplicationScoped | ||
@Interceptors({ResponseErrorLivenessCheck.class, ResponseTimeoutReadinessCheck.class}) | ||
@Interceptors({ ResponseErrorLivenessCheck.class, ResponseTimeoutReadinessCheck.class }) | ||
@Logged | ||
public class IdsResourceImpl implements IdsResource { | ||
|
||
|
@@ -106,19 +107,17 @@ public Response getContentByGlobalId(long globalId, Boolean dereference) { | |
ArtifactTypeUtilProvider artifactTypeProvider = factory.getArtifactTypeProvider(metaData.getType()); | ||
|
||
if (dereference && !artifact.getReferences().isEmpty()) { | ||
if (metaData.getType().equals("JSON")) { | ||
if (ArtifactType.JSON.equals(metaData.getType())) { | ||
RegistryContentUtils.RewrittenContentHolder rewrittenContent = RegistryContentUtils.recursivelyResolveReferencesWithContext(contentToReturn, | ||
metaData.getType(), | ||
artifact.getReferences(), storage::getContentByReference); | ||
|
||
contentToReturn = artifactTypeProvider.getContentDereferencer() | ||
.dereference(rewrittenContent.getRewrittenContent(), rewrittenContent.getResolvedReferences()); | ||
} else { | ||
contentToReturn = artifactTypeProvider.getContentDereferencer().dereference(artifact.getContent(), RegistryContentUtils.recursivelyResolveReferences(artifact.getReferences(), storage::getContentByReference)); | ||
} | ||
else { | ||
contentToReturn = artifactTypeProvider.getContentDereferencer() | ||
.dereference(artifact.getContent(), RegistryContentUtils.recursivelyResolveReferences(artifact.getReferences(), storage::getContentByReference)); | ||
} | ||
} | ||
} | ||
|
||
Response.ResponseBuilder builder = Response.ok(contentToReturn, contentType); | ||
checkIfDeprecated(metaData::getState, metaData.getId(), metaData.getVersion(), builder); | ||
|
@@ -165,7 +164,8 @@ public List<ArtifactReference> referencesByGlobalId(long globalId, ReferenceType | |
return artifact.getReferences().stream() | ||
.map(V2ApiUtil::referenceDtoToReference) | ||
.collect(Collectors.toList()); | ||
} else { | ||
} | ||
else { | ||
ArtifactMetaDataDto amd = storage.getArtifactMetaData(globalId); | ||
return storage.getInboundArtifactReferences(amd.getGroupId(), amd.getId(), amd.getVersion()).stream() | ||
.map(V2ApiUtil::referenceDtoToReference) | ||
|