Interface ClientlibService
-
- All Known Implementing Classes:
DefaultClientlibService
public interface ClientlibService
Various internal functionality about client libraries.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ClientlibService.ClientlibInfo
-
Field Summary
Fields Modifier and Type Field Description static String
ENCODING_GZIP
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clearCache(org.apache.sling.api.resource.ResourceResolver resolver)
Clears the whole cache for all clientlibs.void
deliverContent(org.apache.sling.api.resource.ResourceResolver resolver, ClientlibRef clientlibRef, boolean minified, OutputStream outputStream, String encoding)
Writes the cached content to outputStream.ClientlibConfiguration.Config
getClientlibConfig()
@NotNull org.apache.sling.api.resource.Resource
getMinifiedSibling(@NotNull org.apache.sling.api.resource.Resource resource)
ClientlibService.ClientlibInfo
prepareContent(org.apache.sling.api.SlingHttpServletRequest request, ClientlibRef clientlibRef, boolean minified, String encoding, boolean forceRefreshCache, String requestedHash, long ifModifiedSince)
Writes the content to a cache if it wasn't there, and returns a collection of information to be put into the response headers.void
renderClientlibLinks(ClientlibElement clientlib, Writer writer, org.apache.sling.api.SlingHttpServletRequest request, RendererContext context)
Renders the references to the ressources of the clientlibs into the page.ClientlibElement
resolve(ClientlibRef ref, org.apache.sling.api.resource.ResourceResolver resolver)
Resolves the element corresponding to the ref.@Nullable String
verifyClientlibPermissions(Clientlib.Type type, @Nullable org.apache.sling.api.resource.ResourceResolver resolver, boolean onlyErrors)
Generates a human readable descriptions of inconsistencies of the client libraries wrt.
-
-
-
Field Detail
-
ENCODING_GZIP
static final String ENCODING_GZIP
- See Also:
- Constant Field Values
-
-
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)
-
getClientlibConfig
ClientlibConfiguration.Config getClientlibConfig()
-
renderClientlibLinks
void renderClientlibLinks(ClientlibElement clientlib, Writer writer, org.apache.sling.api.SlingHttpServletRequest request, RendererContext context) throws IOException, javax.jcr.RepositoryException
Renders the references to the ressources of the clientlibs into the page.- Parameters:
clientlib
- aClientlib
orClientlibCategory
- Throws:
IOException
javax.jcr.RepositoryException
-
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 renderminified
- when true, the minified versionencoding
- the needed encoding, if applicableforceRefreshCache
- if true, the cache will be refreshed even if it is up to daterequestedHash
- the hash value the client requestedifModifiedSince
- 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 renderminified
- when true, the minified versionoutputStream
- the stream to write toencoding
- 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 checkedresolver
- if not null, we use this resolver instead of an anonymous resolver to check readabilityonlyErrors
- 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
-
-