Class ArtifactTypeMappingService


  • public class ArtifactTypeMappingService
    extends Object
    Manages the mapping of native artifact types with resource types.
    Since:
    3.7.0
    • Constructor Detail

      • ArtifactTypeMappingService

        public ArtifactTypeMappingService()
    • Method Detail

      • validateArtifactTypeMappings

        protected Feedback validateArtifactTypeMappings​(String containerId,
                                                        Collection<ArtifactTypeMapping> mappings,
                                                        List<String> domains)
                                                 throws ArtifactTypeMappingStoreException
        Validates the artifact type mappings to detect if any of the following issues exists:
        • There are no mappings at all.
        • There are no custom mappings.
        • There are duplicate dialog names (per resource type).
        • There is no default usage (per resource type).
        • There are duplicate usages (per resource type).
        • Configuration is not compliance with CM usages (if apply).

        Applications can override this method to add validations if need it.

        Parameters:
        containerId - the container id.
        mappings - the corresponding resolved mappings.
        Returns:
        a feedback instance.
        Throws:
        ArtifactTypeMappingStoreException - if validations cannot be performed.
      • getSuggestedMappings

        protected List<SuggestedMapping> getSuggestedMappings​(Collection<ArtifactTypeMapping> mappings)
        Verify the mappings to check if better mappings can be suggested. Default implementation returns an empty list, it’s up to each application to override the behavior if required.
        Parameters:
        mappings - the mappings to check
        Returns:
        an empty collection if no suggestion is to make; the suggested mappings otherwise.
      • getResourceTypes

        public Response getResourceTypes​(String containerId)
        Resolves the available resource types.
        Parameters:
        containerId - optional container id. If missing, this service returns the enabled resource types in the ProcessScope; otherwise, it returns the mapped resource types for the given container.
        Returns:
        the available resource types.
        Since:
        3.9.0
      • getUsages

        public Response getUsages​(URI resourceType)
        Resolves the available OSLC usages.
        Returns:
        the available OSLC usages.
      • getArtifactTypeMappings

        public Response getArtifactTypeMappings​(String containerId,
                                                List<String> domains)
        Resolves the Artifact Type Mappings for a container.
        Parameters:
        containerId - the container id.
        domains - the domain URLs to limit the artifact types mappings, an empty list if no filtering is desired.
        Returns:
        the corresponding mappings wrapped along with a feedback if some issues exist.
      • setArtifactTypeMappings

        public Response setArtifactTypeMappings​(String containerId)
        Updates a list of Artifact Type Mappings of a container.
        Parameters:
        containerId - the container id.
        Returns:
        nothing.
      • importArtifactTypeMappings

        public Response importArtifactTypeMappings​(String containerId,
                                                   String importedContainerId,
                                                   String targetContainerTitle)
        Takes the currently mapped artifact type mappings of a container, the artifact type mappings of another container and tries to apply the mapping of the second one to the first one. Nothing is saved in the store, the result is returned and any missing artifact type in the imported artifact type mappings will be listed in a warning feedback. The user will have to save the new mapping separately if he chooses.
        Parameters:
        containerId - the id of the container we're importing to.
        importedContainerId - the id of a different container we want to import the mappings from.
        targetContainerTitle - target container title, to display in feedbacks.
        Returns:
        Since:
        3.9.0
      • restoreArtifactTypeMappings

        public Response restoreArtifactTypeMappings​(String containerId)
        Removes all customized Artifact Type Mappings of a container.
        Parameters:
        containerId - the container id.
        Returns:
        nothing but a success message header.
      • getArtifactTypeMapping

        public Response getArtifactTypeMapping​(String containerId,
                                               String artifactTypeId)
        Resolves the Artifact Type Mapping for a container and artifact type.
        Parameters:
        containerId - the container id.
        artifactTypeId - the artifact type id.
        Returns:
        the corresponding mapping.
      • setArtifactTypeMapping

        public Response setArtifactTypeMapping​(String containerId)
        Updates an Artifact Type Mapping of a container.
        Parameters:
        containerId - the container id.
        Returns:
        the updated mapping.
      • restoreArtifactTypeMapping

        public Response restoreArtifactTypeMapping​(String containerId,
                                                   String artifactTypeId)
        Removes a customized Artifact Type Mapping of a container and artifact type.
        Parameters:
        containerId - the container id.
        artifactTypeId - the artifact type id.
        Returns:
        nothing but a success message header.