public class ConcatenatedResourceStoreImpl extends Object implements ConcatenatedResourceStore
Constructor and Description |
---|
ConcatenatedResourceStoreImpl(Map<String,List<String>> builtInResources,
String contentType,
String fileExtension)
Create a new file store to handle a specific type of files and initialize it with default
categories and some initial resources per category.
|
ConcatenatedResourceStoreImpl(Map<String,List<String>> builtInResources,
String contentType,
String fileExtension,
String minimizedSuffix)
Create a new file store to handle a specific type of files and initialize it with default
categories and some initial resources per category.
|
ConcatenatedResourceStoreImpl(Map<String,List<String>> builtInResources,
String contentType,
String fileExtension,
String minimizedSuffix,
String propertyResourceName)
Create a new file store to handle a specific type of files and initialize it with default
categories and some initial resources per category.
|
Modifier and Type | Method and Description |
---|---|
void |
addCategory(String identifier,
String categoryName,
List<String> coreResources,
List<Pair<String,String>> extensionResources)
Add a category with initial resources.
|
void |
addCategoryWithPropertyResourceSupport(String identifier,
String categoryName,
List<String> coreResources,
List<Pair<String,String>> extensionResources,
String propertyResourceFallback)
Like
ConcatenatedResourceStore.addCategory(String, String, List, List) but adds a category which supports the
definition of a resource as a PluginProperty. |
void |
addToCategory(String identifier,
String categoryName,
List<Pair<String,String>> resources)
Add the resources of a plugin to a category.
|
File |
getConcatenatedFile(String categoryName,
boolean minimized)
Return the concatenated file of a category.
|
long |
getConcatenatedFileLastModified(String categoryName)
Return the timestamp of the last modification of the concatenated file.
|
String |
getContentType() |
List<String> |
getCoreResources(String categoryName,
boolean minimized,
boolean timestamped)
Return the relative locations of the core resources of a given category.
|
protected static File |
getMinimizedFile(String absoluteFilePath,
String minimizedSuffix)
Get the minimized version of a given file if it exists.
|
static String |
getMinimizedResourceName(String resourceName,
String minimizedSuffix)
Return the minimized name of a resource by injecting the marker suffix.
|
String |
getMinimizedSuffix() |
List<String> |
getPluginResources(String categoryName,
boolean minimized,
boolean timestamped)
Return the relative locations of the plugin resources of a given category.
|
PropertyResourceContent |
getPropertyResourceContent(String identifier,
String categoryName)
Get the content of a property resource for category that was added by a given plugin.
|
File |
getPropertyResourceFile(String categoryName,
boolean minimized)
Return the file containing the current value of the property resource of a category.
|
long |
getPropertyResourceLastModified(String categoryName)
Return the timestamp of the last modification of the property resource.
|
void |
init()
Prepare the store after creation.
|
void |
removeCategory(String identifier,
String categoryName)
Remove a category previously added by the plugin with the given identifier.
|
void |
removeFromCategory(String identifier,
String categoryName)
Remove the resources of a category that were added by the plugin with the given identifier
|
void |
setCacheSubdir(String subdirName)
Set the name of the cache sub-directory where concatenated files will be stored.
|
void |
setResourceConcatenator(ResourceConcatenator concatenator)
Set the resource concatenator to use.
|
void |
updatePropertyResource(String identifier,
String categoryName,
String propertyValue)
Update the property resource for the given category and plugin.
|
public ConcatenatedResourceStoreImpl(Map<String,List<String>> builtInResources, String contentType, String fileExtension)
Create a new file store to handle a specific type of files and initialize it with default
categories and some initial resources per category. The initial resources can be overlayed or
extended by plugins via calls to addCategory(String, String, List, List)
and
addToCategory(String, String, List)
respectively. Property resources are not
supported.
The filename suffix marking a file as minimized version is set to "-min".
builtInResources
- mapping from category names to a collection of initial resources of that category.
Each entry of a collection refers to the location of a resource delivered with the
application under which it can be downloaded. The category names represent the
default categories.contentType
- the content/MIME type of the files managed by the storefileExtension
- the extension that all files managed by the store need to havepublic ConcatenatedResourceStoreImpl(Map<String,List<String>> builtInResources, String contentType, String fileExtension, String minimizedSuffix)
addCategory(String, String, List, List)
and
addToCategory(String, String, List)
respectively. Property resources are not
supported.builtInResources
- mapping from category names to a collection of initial resources of that category.
Each entry of a collection refers to the location of a resource delivered with the
application under which it can be downloaded. The category names represent the
default categories.contentType
- the content/MIME type of the files managed by the storefileExtension
- the extension that all files managed by the store need to haveminimizedSuffix
- filename suffix that marks a file as the minimized version of the file with the
same name but without the suffixpublic ConcatenatedResourceStoreImpl(Map<String,List<String>> builtInResources, String contentType, String fileExtension, String minimizedSuffix, String propertyResourceName)
addCategory(String, String, List, List)
and
addToCategory(String, String, List)
respectively.builtInResources
- mapping from category names to a collection of initial resources of that category.
Each entry of a collection refers to the location of a resource delivered with the
application under which it can be downloaded. The category names represent the
default categories.contentType
- the content/MIME type of the files managed by the storefileExtension
- the extension that all files managed by the store need to haveminimizedSuffix
- filename suffix that marks a file as the minimized version of the file with the
same name but without the suffixpropertyResourceName
- identifier for property resources. This identifier is used as prefix for the
property key when storing or retrieving from database. If omitted
PropertyResources are not supported and an exception will be thrown when trying to
add or update a property resource.protected static File getMinimizedFile(String absoluteFilePath, String minimizedSuffix)
absoluteFilePath
- the absolute file name of the fileminimizedSuffix
- filename suffix that marks a file as the minimized version of the file with the
same name but without the suffixpublic static String getMinimizedResourceName(String resourceName, String minimizedSuffix)
resourceName
- the resource name to processminimizedSuffix
- filename suffix that marks a file as the minimized version of the file with the
same name but without the suffixpublic void addCategory(String identifier, String categoryName, List<String> coreResources, List<Pair<String,String>> extensionResources) throws ConcatenatedResourceStoreException
ConcatenatedResourceStore
Add a category with initial resources. If the category already exists because it was added by another plugin via a call to this method or it is one of the built-in categories, the initial resources passed to this method will overlay those of the existing category. That is, the existing initial resources won't be rendered until the plugin removes the category.
When rendering the resources of this category the provided initial resources will be rendered first. Afterwards any plugin resources added to this category byConcatenatedResourceStore.addToCategory(String, String, List)
will be rendered in the order they were added.addCategory
in interface ConcatenatedResourceStore
identifier
- the identifier of the plugincategoryName
- the name of the category to add or create an overlay forcoreResources
- a collection of resources which are delivered with the application and should be
added first when rendering the resources of the given category. Each entry of the
collection refers to the relative location of a resource under which it can be
downloaded. If the file of a resource cannot be resolved it will be ignored. Can
be null if the category does not need to have core resources.extensionResources
- a collection of pairs where each pair describes an initial resource provided by
the plugin. The left part refers to the relative location of the resource under
which it can be downloaded. Therefore, it has to start with the bundle name of the
plugin that is prefixed with a slash. The right part of the pair holds the
absolute file location of the resource on disk. Any resource that does not exist
on disk will be ignored. When rendering the resources of the provided category
these resources will be added after the coreResources. Can be null if the category
does not need to have plugin resources.ConcatenatedResourceStoreException
- in case adding the category failedpublic void addCategoryWithPropertyResourceSupport(String identifier, String categoryName, List<String> coreResources, List<Pair<String,String>> extensionResources, String propertyResourceFallback) throws ConcatenatedResourceStoreException
ConcatenatedResourceStore
ConcatenatedResourceStore.addCategory(String, String, List, List)
but adds a category which supports the
definition of a resource as a PluginProperty. This so called property resource will be
rendered last.addCategoryWithPropertyResourceSupport
in interface ConcatenatedResourceStore
identifier
- the identifier of the plugincategoryName
- the name of the category to add or create an overlay forcoreResources
- a collection of resources which are delivered with the application and should be
added first when rendering the resources of the given category. Each entry of the
collection refers to the relative location of a resource under which it can be
downloaded. If the file of a resource cannot be resolved it will be ignored. Can
be null if the category does not need to have core resources.extensionResources
- a collection of pairs where each pair describes an initial resource provided by
the plugin. The left part refers to the relative location of the resource under
which it can be downloaded. Therefore, it has to start with the bundle name of the
plugin that is prefixed with a slash. The right part of the pair holds the
absolute file location of the resource on disk. Any resource that does not exist
on disk will be ignored. When rendering the resources of the provided category
these resources will be added after the coreResources. Can be null if the category
does not need to have plugin resources.propertyResourceFallback
- a fallback of the property resource which will be included if the property is not
set. Absolute file location of the resource on disk. If not provided or the
resource that does not exist on disk there will be no fallback for the property
resource.ConcatenatedResourceStoreException
- in case property resources are not supported by this store or adding the category
failedpublic void addToCategory(String identifier, String categoryName, List<Pair<String,String>> resources) throws ConcatenatedResourceStoreException
ConcatenatedResourceStore
addToCategory
in interface ConcatenatedResourceStore
identifier
- the identifier of the plugincategoryName
- the name of the category to which the resources should be addedresources
- a collection of pairs where each pair describes a resource of the plugin. The left
part refers to the relative location of the resource under which it can be
downloaded. Therefore, it has to start with the bundle name of the plugin that is
prefixed with a slash. The right part of the pair holds the absolute file location
of the resource on disk. Any resource that does not exist on disk will be ignored.ConcatenatedResourceStoreException
- in case adding the resources to the category failedpublic File getConcatenatedFile(String categoryName, boolean minimized)
ConcatenatedResourceStore
getConcatenatedFile
in interface ConcatenatedResourceStore
categoryName
- the name of the categoryminimized
- whether the minimized version of the file should be returnedpublic long getConcatenatedFileLastModified(String categoryName)
ConcatenatedResourceStore
getConcatenatedFileLastModified
in interface ConcatenatedResourceStore
categoryName
- the name of the categorypublic String getContentType()
getContentType
in interface ConcatenatedResourceStore
public List<String> getCoreResources(String categoryName, boolean minimized, boolean timestamped)
ConcatenatedResourceStore
getCoreResources
in interface ConcatenatedResourceStore
categoryName
- the name of the categoryminimized
- whether to get the location of the minimized versiontimestamped
- if true the last modification timestamp of the file will be append to the location
in the form of a request parameter with name 't'.public String getMinimizedSuffix()
getMinimizedSuffix
in interface ConcatenatedResourceStore
public List<String> getPluginResources(String categoryName, boolean minimized, boolean timestamped)
ConcatenatedResourceStore
ConcatenatedResourceStore.addCategory(String, String, List, List)
or those added via
ConcatenatedResourceStore.addToCategory(String, String, List)
. The relative location represents the location
under which the plugin resource can be downloaded. It starts with a slash followed by the
bundle name of the plugin.getPluginResources
in interface ConcatenatedResourceStore
categoryName
- the name of the categoryminimized
- whether to get the location of the minimized versiontimestamped
- if true the last modification timestamp of the file will be append to the location
in the form of a request parameter with name 't'.public PropertyResourceContent getPropertyResourceContent(String identifier, String categoryName) throws ConcatenatedResourceStoreException
ConcatenatedResourceStore
#getPropertyResource(String)
should be used.getPropertyResourceContent
in interface ConcatenatedResourceStore
identifier
- the identifier of the plugincategoryName
- the name of the categoryConcatenatedResourceStoreException
- in case getting the content failedpublic File getPropertyResourceFile(String categoryName, boolean minimized)
ConcatenatedResourceStore
getPropertyResourceFile
in interface ConcatenatedResourceStore
categoryName
- the name of the categoryminimized
- whether the minimized version of the file should be returnedpublic long getPropertyResourceLastModified(String categoryName)
ConcatenatedResourceStore
getPropertyResourceLastModified
in interface ConcatenatedResourceStore
categoryName
- the name of the categorypublic void init()
public void removeCategory(String identifier, String categoryName) throws ConcatenatedResourceStoreException
removeCategory
in interface ConcatenatedResourceStore
identifier
- the identifier of the plugincategoryName
- the name of the category to removeConcatenatedResourceStoreException
- in case the category couldn't be removed. The store can be in an inconsistent
state.public void removeFromCategory(String identifier, String categoryName) throws ConcatenatedResourceStoreException
removeFromCategory
in interface ConcatenatedResourceStore
identifier
- the identifier of the plugincategoryName
- the name of the category for which the resources should be removedConcatenatedResourceStoreException
- in case the resources of the category couldn't be removed. The store can be in an
inconsistent state.public void setCacheSubdir(String subdirName)
subdirName
- the name of the cache sub-directory to usepublic void setResourceConcatenator(ResourceConcatenator concatenator)
concatenator
- the concatenatorpublic void updatePropertyResource(String identifier, String categoryName, String propertyValue) throws ConcatenatedResourceStoreException
ConcatenatedResourceStore
updatePropertyResource
in interface ConcatenatedResourceStore
identifier
- the identifier of the plugincategoryName
- the name of the categorypropertyValue
- the new value. Can be null to clear the application property and use the fallback
of the plugin.ConcatenatedResourceStoreException
- in case the update failed or the store does not support property resourcesCopyright © 2019 Communote team. All rights reserved.