Package io.apicurio.registry.mt.limits
Class RegistryStorageLimitsEnforcer
- java.lang.Object
-
- io.apicurio.registry.storage.decorator.RegistryStorageDecorator
-
- io.apicurio.registry.mt.limits.RegistryStorageLimitsEnforcer
-
- All Implemented Interfaces:
RegistryStorage
@ApplicationScoped public class RegistryStorageLimitsEnforcer extends RegistryStorageDecorator
Decorator ofRegistryStoragethat applies per-tenant limits enforcement, with this is possible to limit how many artifacts a tenant can create... This feature can also be applied to non multitenancy scenarios, there is the notion of default tenant that can have limits configuration. All of that is abstracted with the TenantLimitsService and the TenantLimitsConfigurationService- Author:
- Fabian Martinez
-
-
Field Summary
-
Fields inherited from class io.apicurio.registry.storage.decorator.RegistryStorageDecorator
delegate
-
-
Constructor Summary
Constructors Constructor Description RegistryStorageLimitsEnforcer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ArtifactMetaDataDtocreateArtifact(String groupId, String artifactId, String version, ArtifactType artifactType, ContentHandle content)Creates a new artifact (from the given value) in the artifactStore.ArtifactMetaDataDtocreateArtifactWithMetadata(String groupId, String artifactId, String version, ArtifactType artifactType, ContentHandle content, EditableArtifactMetaDataDto metaData)Creates a new artifact (from the given value including metadata) in the artifactStore.List<String>deleteArtifact(String groupId, String artifactId)Deletes an artifact by its group and unique id.voiddeleteArtifacts(String groupId)Deletes all artifacts in the given group.voiddeleteArtifactVersion(String groupId, String artifactId, String version)Deletes a single version of a given artifact.booleanisEnabled()intorder()ArtifactMetaDataDtoupdateArtifact(String groupId, String artifactId, String version, ArtifactType artifactType, ContentHandle content)Updates the artifact value by storing the given value as a new version of the artifact.voidupdateArtifactMetaData(String groupId, String artifactId, EditableArtifactMetaDataDto metaData)Updates the stored meta-data for an artifact by group and ID.voidupdateArtifactVersionMetaData(String groupId, String artifactId, String version, EditableArtifactMetaDataDto metaData)Updates the user-editable meta-data for a single version of a given artifact.ArtifactMetaDataDtoupdateArtifactWithMetadata(String groupId, String artifactId, String version, ArtifactType artifactType, ContentHandle content, EditableArtifactMetaDataDto metaData)Updates the artifact value by storing the given value and metadata as a new version of the artifact.io.apicurio.registry.mt.limits.RegistryStorageLimitsEnforcer.ActionProviderwithLimitsCheck(io.apicurio.registry.mt.limits.RegistryStorageLimitsEnforcer.LimitsChecker checker)Notice the "threadContext.withContextCapture" because of using CompletionStage it's possible that certain operations may be executed in different threads.-
Methods inherited from class io.apicurio.registry.storage.decorator.RegistryStorageDecorator
consumeDownload, countArtifacts, countArtifactVersions, countTotalArtifactVersions, createArtifactRule, createDownload, createGlobalRule, createGroup, createRoleMapping, deleteAllExpiredDownloads, deleteAllUserData, deleteArtifactRule, deleteArtifactRules, deleteArtifactVersionMetaData, deleteGlobalRule, deleteGlobalRules, deleteGroup, deleteRoleMapping, exportData, getArtifact, getArtifactByContentHash, getArtifactByContentId, getArtifactIds, getArtifactMetaData, getArtifactMetaData, getArtifactRule, getArtifactRules, getArtifactVersion, getArtifactVersion, getArtifactVersionMetaData, getArtifactVersionMetaData, getArtifactVersions, getArtifactVersionsByContentId, getGlobalRule, getGlobalRules, getGroupIds, getGroupMetaData, getLogConfiguration, getRoleForPrincipal, getRoleMapping, getRoleMappings, importData, isAlive, isReady, listLogConfigurations, removeLogConfiguration, searchArtifacts, searchVersions, setDelegate, setLogConfiguration, storageName, supportsMultiTenancy, updateArtifactRule, updateArtifactState, updateArtifactState, updateGlobalRule, updateGroupMetaData, updateRoleMapping
-
-
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin classRegistryStorageDecorator- See Also:
RegistryStorageDecorator.isEnabled()
-
order
public int order()
- Specified by:
orderin classRegistryStorageDecorator- See Also:
RegistryStorageDecorator.order()
-
createArtifact
public ArtifactMetaDataDto createArtifact(String groupId, String artifactId, String version, ArtifactType artifactType, ContentHandle content) throws ArtifactAlreadyExistsException, RegistryStorageException
Description copied from interface:RegistryStorageCreates a new artifact (from the given value) in the artifactStore. The artifactId must be unique within the given artifact group. Returns a map of meta-data generated by the artifactStore layer, such as the generated, globally unique globalId of the new value. If the group did not exist previously it is created automatically.- Specified by:
createArtifactin interfaceRegistryStorage- Overrides:
createArtifactin classRegistryStorageDecorator- Parameters:
groupId- (optional)version- (optional)- Throws:
ArtifactAlreadyExistsExceptionRegistryStorageException- See Also:
RegistryStorageDecorator.createArtifact(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.types.ArtifactType, io.apicurio.registry.content.ContentHandle)
-
createArtifactWithMetadata
public ArtifactMetaDataDto createArtifactWithMetadata(String groupId, String artifactId, String version, ArtifactType artifactType, ContentHandle content, EditableArtifactMetaDataDto metaData) throws ArtifactAlreadyExistsException, RegistryStorageException
Description copied from interface:RegistryStorageCreates a new artifact (from the given value including metadata) in the artifactStore. The artifactId must be unique within the given artifact group. Returns a map of meta-data generated by the artifactStore layer, such as the generated, globally unique globalId of the new value.- Specified by:
createArtifactWithMetadatain interfaceRegistryStorage- Overrides:
createArtifactWithMetadatain classRegistryStorageDecorator- Parameters:
groupId- (optional)version- (optional)- Throws:
ArtifactAlreadyExistsExceptionRegistryStorageException- See Also:
RegistryStorageDecorator.createArtifactWithMetadata(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.types.ArtifactType, io.apicurio.registry.content.ContentHandle, io.apicurio.registry.storage.dto.EditableArtifactMetaDataDto)
-
updateArtifact
public ArtifactMetaDataDto updateArtifact(String groupId, String artifactId, String version, ArtifactType artifactType, ContentHandle content) throws ArtifactNotFoundException, RegistryStorageException
Description copied from interface:RegistryStorageUpdates the artifact value by storing the given value as a new version of the artifact. Previous value is NOT overwitten. Returns a map of meta-data generated by the artifactStore layer, such as the generated, globally unique globalId of the new value.- Specified by:
updateArtifactin interfaceRegistryStorage- Overrides:
updateArtifactin classRegistryStorageDecorator- Parameters:
groupId- (optional)version- (optional)- Throws:
ArtifactNotFoundExceptionRegistryStorageException- See Also:
RegistryStorageDecorator.updateArtifact(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.types.ArtifactType, io.apicurio.registry.content.ContentHandle)
-
updateArtifactWithMetadata
public ArtifactMetaDataDto updateArtifactWithMetadata(String groupId, String artifactId, String version, ArtifactType artifactType, ContentHandle content, EditableArtifactMetaDataDto metaData) throws ArtifactNotFoundException, RegistryStorageException
Description copied from interface:RegistryStorageUpdates the artifact value by storing the given value and metadata as a new version of the artifact. Previous value is NOT overwitten. Returns a map of meta-data generated by the artifactStore layer, such as the generated, globally unique globalId of the new value.- Specified by:
updateArtifactWithMetadatain interfaceRegistryStorage- Overrides:
updateArtifactWithMetadatain classRegistryStorageDecorator- Parameters:
groupId- (optional)version- (optional)- Throws:
ArtifactNotFoundExceptionRegistryStorageException- See Also:
RegistryStorageDecorator.updateArtifactWithMetadata(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.types.ArtifactType, io.apicurio.registry.content.ContentHandle, io.apicurio.registry.storage.dto.EditableArtifactMetaDataDto)
-
updateArtifactMetaData
public void updateArtifactMetaData(String groupId, String artifactId, EditableArtifactMetaDataDto metaData) throws ArtifactNotFoundException, RegistryStorageException
Description copied from interface:RegistryStorageUpdates the stored meta-data for an artifact by group and ID. Only the client-editable meta-data can be updated. Client editable meta-data includes e.g. name and description. TODO what if set to null?- Specified by:
updateArtifactMetaDatain interfaceRegistryStorage- Overrides:
updateArtifactMetaDatain classRegistryStorageDecorator- Parameters:
groupId- (optional)- Throws:
ArtifactNotFoundExceptionRegistryStorageException- See Also:
RegistryStorageDecorator.updateArtifactMetaData(java.lang.String, java.lang.String, io.apicurio.registry.storage.dto.EditableArtifactMetaDataDto)
-
updateArtifactVersionMetaData
public void updateArtifactVersionMetaData(String groupId, String artifactId, String version, EditableArtifactMetaDataDto metaData) throws ArtifactNotFoundException, VersionNotFoundException, RegistryStorageException
Description copied from interface:RegistryStorageUpdates the user-editable meta-data for a single version of a given artifact. Only the client-editable meta-data can be updated. Client editable meta-data includes e.g. name and description.- Specified by:
updateArtifactVersionMetaDatain interfaceRegistryStorage- Overrides:
updateArtifactVersionMetaDatain classRegistryStorageDecorator- Parameters:
groupId- (optional)- Throws:
ArtifactNotFoundExceptionVersionNotFoundExceptionRegistryStorageException- See Also:
RegistryStorageDecorator.updateArtifactVersionMetaData(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.storage.dto.EditableArtifactMetaDataDto)
-
deleteArtifact
public List<String> deleteArtifact(String groupId, String artifactId) throws ArtifactNotFoundException, RegistryStorageException
Description copied from interface:RegistryStorageDeletes an artifact by its group and unique id. Returns list of artifact versions.- Specified by:
deleteArtifactin interfaceRegistryStorage- Overrides:
deleteArtifactin classRegistryStorageDecorator- Parameters:
groupId- (optional)- Throws:
ArtifactNotFoundExceptionRegistryStorageException- See Also:
RegistryStorageDecorator.deleteArtifact(java.lang.String, java.lang.String)
-
deleteArtifacts
public void deleteArtifacts(String groupId) throws RegistryStorageException
Description copied from interface:RegistryStorageDeletes all artifacts in the given group. DOES NOT delete the group.- Specified by:
deleteArtifactsin interfaceRegistryStorage- Overrides:
deleteArtifactsin classRegistryStorageDecorator- Parameters:
groupId- (optional)- Throws:
RegistryStorageException- See Also:
RegistryStorageDecorator.deleteArtifacts(java.lang.String)
-
deleteArtifactVersion
public void deleteArtifactVersion(String groupId, String artifactId, String version) throws ArtifactNotFoundException, VersionNotFoundException, RegistryStorageException
Description copied from interface:RegistryStorageDeletes a single version of a given artifact.- Specified by:
deleteArtifactVersionin interfaceRegistryStorage- Overrides:
deleteArtifactVersionin classRegistryStorageDecorator- Parameters:
groupId- (optional)- Throws:
ArtifactNotFoundExceptionVersionNotFoundExceptionRegistryStorageException- See Also:
RegistryStorageDecorator.deleteArtifactVersion(java.lang.String, java.lang.String, java.lang.String)
-
withLimitsCheck
public io.apicurio.registry.mt.limits.RegistryStorageLimitsEnforcer.ActionProvider withLimitsCheck(io.apicurio.registry.mt.limits.RegistryStorageLimitsEnforcer.LimitsChecker checker)
Notice the "threadContext.withContextCapture" because of using CompletionStage it's possible that certain operations may be executed in different threads. But we have the TenantContext that stores per-tenant configurations in a ThreadLocale variable. We need context propagation to move the ThreadLocale context from one thread to another, that's why we use withContextCapture- Parameters:
checker-- Returns:
-
-