Class ArtifactTypeMapper

    • Method Detail

      • onResourceTypeChange

        public static void onResourceTypeChange​(Consumer<ResourceTypeChange> action)
        Registers an action to get executed when a resource type mapping changes.

        Changes that occurred before the registration are not notified, registrations should be done at application startup. All actions will be executed on a dedicated thread and no exceptions must be thrown but handled internally.

        Actions are all automatically unregistered when the application is disposed.

        Parameters:
        action - the action to execute.
        Since:
        3.9.0
      • offResourceTypeChange

        public static void offResourceTypeChange​(Consumer<ResourceTypeChange> action)
        Removes an action from being notified when a resource type mapping changes.

        Actions are all automatically unregistered when the application is disposed.

        Parameters:
        action - the action to execute.
        Since:
        3.9.0
      • getArtifactTypeMapping

        public static ArtifactTypeMapping getArtifactTypeMapping​(String containerId,
                                                                 String artifactType,
                                                                 List<Locale> locales)
                                                          throws ArtifactTypeMappingStoreException
        Resolves the artifact type mapping for a given container and artifact type.

        This method must be used, instead of using directly the store, to get the saved custom mapping, if any, merged with the application default's.

        Parameters:
        containerId - the container id.
        artifactType - the artifact type id.
        locales - the preferred Locales for label translations.
        Returns:
        the corresponding mapping.
        Throws:
        ArtifactTypeMappingStoreException - if mapping cannot be resolved.
      • getArtifactTypeMappings

        public static Collection<ArtifactTypeMapping> getArtifactTypeMappings​(String containerId,
                                                                              List<Locale> locales)
                                                                       throws ArtifactTypeMappingStoreException
        Resolves the artifact type mappings for a given container.

        This method must be used, instead of using directly the store, to get any saved custom mapping merged with the application default's.

        Parameters:
        containerId - the container id.
        locales - the preferred Locales for label translations.
        Returns:
        the corresponding artifact type mappings of containerId.
        Throws:
        ArtifactTypeMappingStoreException - if custom mappings cannot be resolved.
      • removeCustomArtifactTypeMapping

        public static void removeCustomArtifactTypeMapping​(String containerId,
                                                           String artifactTypeId,
                                                           List<Locale> locales)
                                                    throws ArtifactTypeMappingStoreException
        Deletes customization for an artifact type mapping and notify if there is a resource type change.
        Parameters:
        containerId - the container id.
        artifactTypeId - the artifactTypeId
        Throws:
        ArtifactTypeMappingStoreException - if the custom mapping cannot be resolved.
      • removeCustomArtifactTypeMappings

        public static void removeCustomArtifactTypeMappings​(String containerId,
                                                            List<Locale> locales)
                                                     throws ArtifactTypeMappingStoreException
        * Deletes customization for all artifact type mappings in a container and notify if there are resource type changes.
        Parameters:
        containerId - the container id.
        Throws:
        ArtifactTypeMappingStoreException - if custom mappings cannot be resolved.
      • setArtifactTypeMapping

        public static void setArtifactTypeMapping​(String containerId,
                                                  ArtifactTypeMapping mapping,
                                                  List<Locale> locales)
                                           throws ArtifactTypeMappingStoreException
        Sets or updates a custom artifact type mapping.

        This method must be used, instead of using directly the store, to avoid storing custom mappings when they are equal to the default's. This method also removes a previously saved custom mapping, if the mapping to store is equal to the default's.

        Parameters:
        containerId - the container id.
        mapping - the custom mapping.
        locales - the preferred Locales for label translations.
        Throws:
        ArtifactTypeMappingStoreException - if the storage fails.
      • getSupportedResourceTypes

        public static Set<Link> getSupportedResourceTypes​(List<Locale> locales)
        Gets the application-supported set of resource types.
        Parameters:
        locales - the preferred Locales for label translations.
        Returns:
        the application-supported resource types.
        Since:
        3.9.0
      • getMappedResourceTypes

        public static Set<Link> getMappedResourceTypes​(String containerId,
                                                       List<Locale> locales)
                                                throws ArtifactTypeMappingStoreException
        Gets the mapped resource types of a given container.
        Parameters:
        containerId - the given container id.
        locales - the preferred Locales for label translations.
        Returns:
        the mapped resource types of a given container.
        Throws:
        ArtifactTypeMappingStoreException - if the storage fails.
        Since:
        3.9.0