Class ArtifactTypeMappingStore
- java.lang.Object
-
- com.sodius.oslc.server.process.types.ArtifactTypeMappingStore
-
public abstract class ArtifactTypeMappingStore extends Object
Manages persistence ofArtifactTypeMapping
instances.Applications providing a store implementation MUST override
ApplicationArtifactResolver.resolveArtifactTypeMapping(ApplicationArtifact, ApplicationArtifact, HttpServletRequest)
as well.- Since:
- 3.7.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ArtifactTypeMappingStore.ArtifactTypeMappingValue
The resource type mapped to a native artifact type for linking (with possibly some policies).
-
Constructor Summary
Constructors Constructor Description ArtifactTypeMappingStore()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Optional<ArtifactTypeMappingStore.ArtifactTypeMappingValue>
getCustomArtifactTypeMapping(String containerId, String artifactTypeId)
Gets the custom artifact type mapping of a container and an artifact type.abstract Map<String,ArtifactTypeMappingStore.ArtifactTypeMappingValue>
getCustomArtifactTypeMappings(String containerId)
Gets the custom artifact type mappings of a container.abstract ArtifactTypeMapping
getDefaultArtifactTypeMapping(String containerId, String artifactTypeId)
Gets the default artifact type mapping of a container and artifact type.abstract Collection<ArtifactTypeMapping>
getDefaultArtifactTypeMappings(String containerId)
Gets the default artifact type mappings of a container.static ArtifactTypeMappingStore
getInstance()
Returns the current store instance.void
onResourceTypeChanged(String containerId, String artifactTypeId, URI oldResourceType, URI newResourceType)
Invoked whenever a resource type mapping is detected, implementations can override the default NO-OP operation to perform related operations.abstract void
removeCustomArtifactTypeMapping(String containerId, String artifactTypeId)
Removes a custom mapping.abstract void
removeCustomArtifactTypeMappings(String containerId)
Removes all custom mappings of a container.abstract void
saveArtifactTypeMapping(String containerId, String artifactTypeId, ArtifactTypeMappingStore.ArtifactTypeMappingValue mapping)
Stores a custom artifact type mapping of a container and artifact type.static void
setInstance(ArtifactTypeMappingStore store)
Replaces the current store instance with the given one.
-
-
-
Method Detail
-
getInstance
public static ArtifactTypeMappingStore getInstance()
Returns the current store instance.- Returns:
- the current instance.
- See Also:
setInstance(ArtifactTypeMappingStore)
-
setInstance
public static void setInstance(ArtifactTypeMappingStore store)
Replaces the current store instance with the given one.Applications providing a store implementation MUST override
ApplicationArtifactResolver.resolveArtifactTypeMapping(ApplicationArtifact, ApplicationArtifact, HttpServletRequest)
as well.- Parameters:
store
- the new store.
-
getDefaultArtifactTypeMapping
public abstract ArtifactTypeMapping getDefaultArtifactTypeMapping(String containerId, String artifactTypeId) throws ArtifactTypeMappingStoreException
Gets the default artifact type mapping of a container and artifact type. This is the mapping to use when no customization has been done.- Parameters:
containerId
- the container id.artifactTypeId
- the artifact type id.- Returns:
- the corresponding default mapping.
- Throws:
ArtifactTypeMappingStoreException
- if the mapping does not exists or an error occurs while querying the store.
-
getDefaultArtifactTypeMappings
public abstract Collection<ArtifactTypeMapping> getDefaultArtifactTypeMappings(String containerId) throws ArtifactTypeMappingStoreException
Gets the default artifact type mappings of a container. These are the mappings to use when no customization has been done.Implementations must provide a mapping for each valid artifact type, in the underlying application, at the moment this method is invoked.
- Parameters:
containerId
- the container id.- Returns:
- the default artifact type mappings.
- Throws:
ArtifactTypeMappingStoreException
- if an error occurs while querying the store.
-
getCustomArtifactTypeMapping
public abstract Optional<ArtifactTypeMappingStore.ArtifactTypeMappingValue> getCustomArtifactTypeMapping(String containerId, String artifactTypeId) throws ArtifactTypeMappingStoreException
Gets the custom artifact type mapping of a container and an artifact type.- Parameters:
containerId
- the container id.artifactTypeId
- the artifact type id.- Returns:
- an empty optional if no custom mapping exist for the given container and artifact type; its contained reference otherwise.
- Throws:
ArtifactTypeMappingStoreException
- if an error occurs while querying the store.
-
getCustomArtifactTypeMappings
public abstract Map<String,ArtifactTypeMappingStore.ArtifactTypeMappingValue> getCustomArtifactTypeMappings(String containerId) throws ArtifactTypeMappingStoreException
Gets the custom artifact type mappings of a container.- Parameters:
containerId
- the container id.- Returns:
- an empty map if no custom mappings are stored; a map whose
key
is the native artifact type identifier andvalue
is the custom artifact type mapping otherwise. - Throws:
ArtifactTypeMappingStoreException
- if an error occurs while querying the store.
-
saveArtifactTypeMapping
public abstract void saveArtifactTypeMapping(String containerId, String artifactTypeId, ArtifactTypeMappingStore.ArtifactTypeMappingValue mapping) throws ArtifactTypeMappingStoreException
Stores a custom artifact type mapping of a container and artifact type.- Parameters:
containerId
- the container id.artifactTypeId
- the artifact type id.- Throws:
ArtifactTypeMappingStoreException
- if an error occurs while saving the store.
-
removeCustomArtifactTypeMapping
public abstract void removeCustomArtifactTypeMapping(String containerId, String artifactTypeId) throws ArtifactTypeMappingStoreException
Removes a custom mapping.- Parameters:
containerId
- the container id.artifactTypeId
- the artifact type id.- Throws:
ArtifactTypeMappingStoreException
- if an error occurs while removing from the store.
-
removeCustomArtifactTypeMappings
public abstract void removeCustomArtifactTypeMappings(String containerId) throws ArtifactTypeMappingStoreException
Removes all custom mappings of a container.- Parameters:
containerId
- the container id.- Throws:
ArtifactTypeMappingStoreException
- if an error occurs while removing from the store.
-
onResourceTypeChanged
public void onResourceTypeChanged(String containerId, String artifactTypeId, URI oldResourceType, URI newResourceType)
Invoked whenever a resource type mapping is detected, implementations can override the default NO-OP operation to perform related operations.- Parameters:
containerId
- the container id.artifactTypeId
- the artifact type id.oldResourceType
- the former resource type URI.newResourceType
- the current resource type URI.
-
-