Skip to content

Commit

Permalink
feat: skip disabled artifact versions when looking for latest (Apicur…
Browse files Browse the repository at this point in the history
…io#2862)

* feat: skip disabled artifact versions when looking for latest version

* docs: regenerate configuration list

* chore: update my @author tag to avoid javadoc warnings
  • Loading branch information
jsenko authored Apr 6, 2023
1 parent 5c18a2e commit 9208793
Show file tree
Hide file tree
Showing 139 changed files with 1,118 additions and 831 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import javax.inject.Inject;
import javax.interceptor.InvocationContext;

import static io.apicurio.registry.storage.RegistryStorage.ArtifactRetrievalBehavior.DEFAULT;

public abstract class AbstractAccessController implements IAccessController {

@Inject
Expand Down Expand Up @@ -57,7 +59,7 @@ private boolean verifyGroupCreatedBy(String groupId) {

private boolean verifyArtifactCreatedBy(String groupId, String artifactId) {
try {
ArtifactMetaDataDto dto = storage.getArtifactMetaData(groupId, artifactId);
ArtifactMetaDataDto dto = storage.getArtifactMetaData(groupId, artifactId, DEFAULT);
String createdBy = dto.getCreatedBy();
return createdBy == null || createdBy.equals(securityIdentity.getPrincipal().getName());
} catch (NotFoundException nfe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Immutable.
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@JsonAutoDetect(isGetterVisibility = NONE)
@NoArgsConstructor // required for Jackson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Immutable.
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@JsonAutoDetect(isGetterVisibility = NONE)
@NoArgsConstructor // required for Jackson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@JsonAutoDetect(isGetterVisibility = NONE)
@NoArgsConstructor // required for Jackson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;

/**
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
* @author Carles Arnal '[email protected]'
*/
@JsonAutoDetect(isGetterVisibility = NONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;

/**
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@JsonAutoDetect(isGetterVisibility = NONE)
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;

/**
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@JsonAutoDetect(isGetterVisibility = NONE)
@NoArgsConstructor // required for Jackson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ public class SubjectVersion {
private String subject;

@JsonProperty("version")
private Long version;
private Long version; // TODO How is this used?
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
public final class ContentTypes {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
public class Errors {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* The compatibility resource allows the user to test schemas for compatibility against specific versions of a subject’s schema.
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Path("/apis/ccompat/v6/compatibility")
@Consumes({JSON, OCTET_STREAM, COMPAT_SCHEMA_REGISTRY_V1, COMPAT_SCHEMA_REGISTRY_STABLE_LATEST})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* The config resource allows you to inspect the cluster-level configuration values as well as subject overrides.
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Path("/apis/ccompat/v6/config")
@Consumes({JSON, OCTET_STREAM, COMPAT_SCHEMA_REGISTRY_V1, COMPAT_SCHEMA_REGISTRY_STABLE_LATEST})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* We <b>DO NOT</b> support this endpoint. Fails with 404.
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Path("/apis/ccompat/v6/mode")
@Consumes({JSON, OCTET_STREAM, COMPAT_SCHEMA_REGISTRY_V1, COMPAT_SCHEMA_REGISTRY_STABLE_LATEST})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* This <a href="https://docs.confluent.io/5.5.0/schema-registry/develop/api.html#schemas">API specification</a> is owned by Confluent.
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Path("/apis/ccompat/v6/schemas")
@Consumes({JSON, OCTET_STREAM, COMPAT_SCHEMA_REGISTRY_V1, COMPAT_SCHEMA_REGISTRY_STABLE_LATEST})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Path("/apis/ccompat/v6/subjects/{subject}/versions")
@Consumes({JSON, OCTET_STREAM, COMPAT_SCHEMA_REGISTRY_V1, COMPAT_SCHEMA_REGISTRY_STABLE_LATEST})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* This <a href="https://docs.confluent.io/5.5.0/schema-registry/develop/api.html#subjects">API specification</a> is owned by Confluent.
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Path("/apis/ccompat/v6/subjects")
@Consumes({JSON, OCTET_STREAM, COMPAT_SCHEMA_REGISTRY_V1, COMPAT_SCHEMA_REGISTRY_STABLE_LATEST})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
public abstract class AbstractResource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/

@ApplicationScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Interceptors({ResponseErrorLivenessCheck.class, ResponseTimeoutReadinessCheck.class})
@Logged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* We <b>DO NOT</b> support this endpoint. Fails with 404.
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Interceptors({ResponseErrorLivenessCheck.class, ResponseTimeoutReadinessCheck.class})
@Logged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Interceptors({ResponseErrorLivenessCheck.class, ResponseTimeoutReadinessCheck.class})
@Logged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Interceptors({ResponseErrorLivenessCheck.class, ResponseTimeoutReadinessCheck.class})
@Logged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
@Interceptors({ResponseErrorLivenessCheck.class, ResponseTimeoutReadinessCheck.class})
@Logged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*
*
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
*/
public interface RegistryStorageFacade {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import static io.apicurio.registry.storage.RegistryStorage.ArtifactRetrievalBehavior.DEFAULT;

/**
* @author Ales Justin
* @author Jakub Senko '[email protected]'
* @author Jakub Senko <em>[email protected]</em>
* @author Carles Arnal
*/
@ApplicationScoped
Expand Down Expand Up @@ -170,9 +172,6 @@ public Schema getSchema(String subject, String versionString) throws ArtifactNot
return parseVersionString(subject, versionString,
version -> {
ArtifactVersionMetaDataDto artifactVersionMetaDataDto = storage.getArtifactVersionMetaData(null, subject, version);
if (ArtifactState.DISABLED.equals(artifactVersionMetaDataDto.getState())) {
throw new VersionNotFoundException(null, subject, version);
}
StoredArtifactDto storedArtifact = storage.getArtifactVersion(null, subject, version);
return converter.convert(subject, storedArtifact, artifactVersionMetaDataDto.getType());
});
Expand Down Expand Up @@ -398,8 +397,12 @@ public <T> T parseVersionString(String subject, String versionString, Function<S
}

private String getLatestArtifactVersionForSubject(String subject) {
ArtifactMetaDataDto latest = storage.getArtifactMetaData(null, subject);
return latest.getVersion();
try {
ArtifactMetaDataDto latest = storage.getArtifactMetaData(null, subject);
return latest.getVersion();
} catch (ArtifactNotFoundException ex) {
throw new VersionNotFoundException(null, subject, "latest");
}
}

@Override
Expand Down Expand Up @@ -437,10 +440,9 @@ public List<Long> getContentIdsReferencingArtifact(String subject, String versio
version -> storage.getContentIdsReferencingArtifact(null, subject, version));
}


private boolean doesArtifactExist(String artifactId) {
try {
storage.getArtifact(null, artifactId);
storage.getArtifact(null, artifactId, DEFAULT);
return true;
} catch (ArtifactNotFoundException ignored) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.apicurio.registry.cncf.schemaregistry.impl;

import io.apicurio.common.apps.logging.Logged;
import io.apicurio.registry.auth.Authorized;
import io.apicurio.registry.auth.AuthorizedLevel;
import io.apicurio.registry.auth.AuthorizedStyle;
Expand All @@ -25,7 +26,6 @@
import io.apicurio.registry.cncf.schemaregistry.beans.SchemaGroup;
import io.apicurio.registry.cncf.schemaregistry.beans.SchemaId;
import io.apicurio.registry.content.ContentHandle;
import io.apicurio.common.apps.logging.Logged;
import io.apicurio.registry.metrics.health.liveness.ResponseErrorLivenessCheck;
import io.apicurio.registry.metrics.health.readiness.ResponseTimeoutReadinessCheck;
import io.apicurio.registry.rules.RuleApplicationType;
Expand All @@ -51,13 +51,6 @@
import io.apicurio.registry.util.VersionUtil;
import io.quarkus.security.identity.SecurityIdentity;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.interceptor.Interceptors;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import java.io.InputStream;
import java.util.Collections;
import java.util.Date;
Expand All @@ -66,8 +59,16 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.interceptor.Interceptors;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;

import static io.apicurio.registry.cncf.schemaregistry.impl.CNCFApiUtil.dtoToSchemaGroup;
import static io.apicurio.registry.storage.RegistryStorage.ArtifactRetrievalBehavior.DEFAULT;

/**
* @author Fabian Martinez
Expand Down Expand Up @@ -277,7 +278,7 @@ public void deleteSchemaVersion(String groupId, String schemaId, Integer version

private boolean artifactExists(String groupId, String schemaId) {
try {
storage.getArtifactMetaData(groupId, schemaId);
storage.getArtifactMetaData(groupId, schemaId, DEFAULT);
return true;
} catch (ArtifactNotFoundException ignored) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Periodically cleanup data of tenants marked as deleted.
*
* @author Jakub Senko <[email protected]>
* @author Jakub Senko <em>[email protected]</em>
*/
@ApplicationScoped
public class DownloadReaper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@
*/
package io.apicurio.registry.events;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import io.apicurio.registry.content.ContentHandle;
import io.apicurio.registry.events.dto.ArtifactId;
import io.apicurio.registry.events.dto.ArtifactRuleChange;
Expand Down Expand Up @@ -53,6 +45,14 @@
import io.apicurio.registry.types.ArtifactState;
import io.apicurio.registry.types.RuleType;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

/**
* @author Fabian Martinez
*/
Expand Down Expand Up @@ -159,6 +159,11 @@ public StoredArtifactDto getArtifact(String groupId, String artifactId) throws A
return delegate.getArtifact(groupId, artifactId);
}

@Override
public StoredArtifactDto getArtifact(String groupId, String artifactId, ArtifactRetrievalBehavior behavior) throws ArtifactNotFoundException, RegistryStorageException {
return delegate.getArtifact(groupId, artifactId, behavior);
}

@Override
public ContentWrapperDto getArtifactByContentHash(String contentHash) throws ContentNotFoundException, RegistryStorageException {
return delegate.getArtifactByContentHash(contentHash);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.apicurio.registry.faulttolerance;

/**
* @author Jakub Senko <[email protected]>
* @author Jakub Senko <em>[email protected]</em>
*/
public interface FaultToleranceConstants {

Expand Down
Loading

0 comments on commit 9208793

Please sign in to comment.