Class MediaLinkType


  • @Model(adaptables={org.apache.sling.api.SlingHttpServletRequest.class,org.apache.sling.api.resource.Resource.class})
    @ProviderType
    public final class MediaLinkType
    extends LinkType
    Default implementation of LinkType for media links. Media links are links to media items from media sources that implement the MediaSource interface.
    • Constructor Detail

      • MediaLinkType

        public MediaLinkType()
    • Method Detail

      • getId

        @NotNull
        public @NotNull String getId()
        Specified by:
        getId in class LinkType
        Returns:
        Link type ID (is stored as identifier in repository)
      • getLabel

        @NotNull
        public @NotNull String getLabel()
        Overrides:
        getLabel in class LinkType
        Returns:
        Link type label (displayed in link dialogs)
      • getPrimaryLinkRefProperty

        public String getPrimaryLinkRefProperty()
        Specified by:
        getPrimaryLinkRefProperty in class LinkType
        Returns:
        Name of the property in which the primary link reference is stored
      • accepts

        public boolean accepts​(@NotNull
                               @NotNull String linkRef)
        Description copied from class: LinkType
        Checks whether a link reference string can be handled by this link type
        Specified by:
        accepts in class LinkType
        Parameters:
        linkRef - Link reference string
        Returns:
        true if this link type can handle the given link reference
      • resolveLink

        @NotNull
        public @NotNull Link resolveLink​(@NotNull
                                         @NotNull Link link)
        Description copied from class: LinkType
        Resolves a link
        Specified by:
        resolveLink in class LinkType
        Parameters:
        link - Link metadata
        Returns:
        Resolved link metadata. Never null.
      • isDefaultMediaContentPath

        public static boolean isDefaultMediaContentPath​(String path)
        Parameters:
        path - Content path
        Returns:
        true if Path is located below DAM default root folders.
      • getSyntheticLinkResource

        @NotNull
        public static @NotNull org.apache.sling.api.resource.Resource getSyntheticLinkResource​(@NotNull
                                                                                               @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver,
                                                                                               @NotNull
                                                                                               @NotNull String path,
                                                                                               @NotNull
                                                                                               @NotNull String mediaRef)
        Get synthetic link resource for this link type.
        Parameters:
        resourceResolver - Resource resolver
        path - Resource path. Can be a non-existing path, but the path should be located somewhere within the applications content paths to make sure the handler configuration looked up via context-aware services is the expected one.
        mediaRef - Media asset reference
        Returns:
        Synthetic link resource
      • getSyntheticLinkResource

        @Deprecated
        @NotNull
        public static @NotNull org.apache.sling.api.resource.Resource getSyntheticLinkResource​(@NotNull
                                                                                               @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver,
                                                                                               @NotNull
                                                                                               @NotNull String mediaRef)
        Get synthetic link resource for this link type.
        Parameters:
        resourceResolver - Resource resolver
        mediaRef - Media asset reference
        Returns:
        Synthetic link resource