Interface ClientlibService

  • All Known Implementing Classes:
    DefaultClientlibService

    public interface ClientlibService
    Various internal functionality about client libraries.
    • Method Detail

      • resolve

        ClientlibElement resolve​(ClientlibRef ref,
                                 org.apache.sling.api.resource.ResourceResolver resolver)
        Resolves the element corresponding to the ref.
        Returns:
        the corresponding element or null if we can't find it.
      • getMinifiedSibling

        @NotNull
        @NotNull org.apache.sling.api.resource.Resource getMinifiedSibling​(@NotNull
                                                                           @NotNull org.apache.sling.api.resource.Resource resource)
      • prepareContent

        ClientlibService.ClientlibInfo prepareContent​(org.apache.sling.api.SlingHttpServletRequest request,
                                                      ClientlibRef clientlibRef,
                                                      boolean minified,
                                                      String encoding,
                                                      boolean forceRefreshCache,
                                                      String requestedHash,
                                                      long ifModifiedSince)
                                               throws IOException,
                                                      javax.jcr.RepositoryException
        Writes the content to a cache if it wasn't there, and returns a collection of information to be put into the response headers.
        Parameters:
        clientlibRef - reference to the clientlib / category to render
        minified - when true, the minified version
        encoding - the needed encoding, if applicable
        forceRefreshCache - if true, the cache will be refreshed even if it is up to date
        requestedHash - the hash value the client requested
        ifModifiedSince - the value of the If-Modified-Since header, if present
        Returns:
        information about the file
        Throws:
        IOException
        javax.jcr.RepositoryException
      • deliverContent

        void deliverContent​(org.apache.sling.api.resource.ResourceResolver resolver,
                            ClientlibRef clientlibRef,
                            boolean minified,
                            OutputStream outputStream,
                            String encoding)
                     throws IOException,
                            javax.jcr.RepositoryException
        Writes the cached content to outputStream.
        Parameters:
        clientlibRef - reference to the clientlib / category to render
        minified - when true, the minified version
        outputStream - the stream to write to
        encoding - the needed encoding, if applicable
        Throws:
        IOException
        javax.jcr.RepositoryException
      • verifyClientlibPermissions

        @Nullable
        @Nullable String verifyClientlibPermissions​(@Nullable
                                                    Clientlib.Type type,
                                                    @Nullable
                                                    @Nullable org.apache.sling.api.resource.ResourceResolver resolver,
                                                    boolean onlyErrors)
        Generates a human readable descriptions of inconsistencies of the client libraries wrt. the given resolver (or an anonymous resolver, of none is given). Checks for each client library readable for the given resolver, that all elements of these client libraries and the files referenced from them are readable, too. Also we check that for all categories either all client libraries with this reference are readable, or none of them. All these are errors, since if that's not the case, this can cause a permanent recalculation of the clientlibs content, or, even worse, break the rendering. If {onlyErrors} is false, we also include informational messages about all unreadable libraries.
        Parameters:
        type - if not null, only clientlibs / files of that type are checked
        resolver - if not null, we use this resolver instead of an anonymous resolver to check readability
        onlyErrors - if true, we skip informational messages
        Returns:
        null if everything is OK, otherwise a description of the problems
      • clearCache

        void clearCache​(org.apache.sling.api.resource.ResourceResolver resolver)
                 throws org.apache.sling.api.resource.PersistenceException
        Clears the whole cache for all clientlibs. Obviously something to used sparingly.
        Parameters:
        resolver - the resolver to use.
        Throws:
        org.apache.sling.api.resource.PersistenceException