|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.rice.krad.theme.postprocessor.ThemeFilesProcessor
public abstract class ThemeFilesProcessor
Base class for the JS and CSS theme file processors (or post-processors) that act on a given theme
The post processing of JS and CSS files is orchestrated in this base class with the specific configuration
for each provided through abstract methods. This process()
method performs the major calls of
the process
Base class also provides some helper methods such as getPropertyValueAsPluginDirs(java.lang.String)
and #addMissingPluginDirs(java.util.List
Field Summary | |
---|---|
protected static String |
PLUGIN_FILES_KEY
|
protected String |
projectVersion
|
protected static String |
SUBDIR_FILES_KEY
|
protected File |
themeDirectory
|
protected String |
themeName
|
protected Map<String,File> |
themePluginDirsMap
|
protected Properties |
themeProperties
|
protected File |
workingDir
|
Constructor Summary | |
---|---|
ThemeFilesProcessor(String themeName,
File themeDirectory,
Properties themeProperties,
Map<String,File> themePluginDirsMap,
File workingDir,
String projectVersion)
|
Method Summary | |
---|---|
protected abstract void |
addAdditionalFiles(List<File> themeFiles)
Invoked during the collection of files to allow additional files to be added to the theme's list |
protected List<File> |
addMissingPluginDirs(List<File> pluginList)
Helper method to add any plugin directories for the theme being processed to the given list if they are not already contained in the list |
protected Map<String,List<File>> |
collectThemeFiles()
Collects the file names to include for the theme, separated by whether they come from a plugin directory or the theme directory |
protected File |
createMergedFile(boolean minified)
Creates a new file that will hold the merged or minified contents |
protected abstract String |
getExcludesConfigKey()
Key for the property within the theme's properties file that can be configured to exlcude files of the type being processed |
protected String[] |
getFileExcludes()
Builds array of patterns used to exclude files to include for the type |
protected String[] |
getFileIncludes()
Builds array of patterns used to find files to include for the type, by default picks up all files that have the extension for the type being processed |
protected abstract String |
getFileListingConfigKey()
Key for the property that will be written to the theme derived properties to list the included files for the file type |
protected abstract String |
getFileTypeDirectoryName()
Name of the directory relative to the theme directory which contains files for the type |
protected abstract String |
getFileTypeExtension()
Extension (ex. |
protected File |
getFileTypeSubDirectory()
Returns the File object that points to the theme subdirectory that contains files for the file type |
protected List<File> |
getPropertyValueAsPluginDirs(String propertyKey)
Helper method that retrieves the value for the given property from the theme's properties as a list of file objects that point to plugin directories |
protected List<String> |
getThemePropertyValue(String propertyKey)
Helper method that retrieves the value for the given property from the theme's properties as a list of strings |
protected void |
mergeFiles(List<File> filesToMerge,
File mergedFile)
Merges the content from the list of files into the given merge file |
protected abstract void |
minify(File mergedFile,
File minifiedFile)
Invoked after the merged file has been created to create the minified version |
void |
process()
Carries out the theme files post process |
protected abstract String |
processMergeFileContents(String fileContents,
File fileToMerge,
File mergedFile)
Invoked during the merge process to alter the given file contents before they are appended to the merge file |
protected abstract List<File> |
sortThemeFiles(List<File> pluginFiles,
List<File> subDirFiles)
Invoked to build the final sorted list of files for the type, files from plugins and from the theme's sub directory are passed separately so special treatment can be given to those for sorting |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String PLUGIN_FILES_KEY
protected static final String SUBDIR_FILES_KEY
protected String themeName
protected File themeDirectory
protected Properties themeProperties
protected Map<String,File> themePluginDirsMap
protected File workingDir
protected String projectVersion
Constructor Detail |
---|
public ThemeFilesProcessor(String themeName, File themeDirectory, Properties themeProperties, Map<String,File> themePluginDirsMap, File workingDir, String projectVersion)
Method Detail |
---|
public void process()
Processing of each file type includes the following:
Any IOException
that occur are caught and thrown as runtime exceptions
protected Map<String,List<File>> collectThemeFiles()
First all plugin directories that are included for the theme are listed based on the include for that
file type getFileIncludes()
. Individual plugin files can be excluded with the property
pluginFileExcludes
, or the global excludes for the file type getFileExcludes()
Next the subdirectory of the theme that holds the file type, given by getFileTypeSubDirectory()
,
is listed to pick up include files. Again the global file includes and excludes for the type is used
Finally, subclasses can add additional files by implementing addAdditionalFiles(java.util.List)
PLUGIN_FILES_KEY
and SUBDIR_FILES_KEY
getFileIncludes()
,
getFileExcludes()
,
getFileTypeSubDirectory()
,
addAdditionalFiles(java.util.List)
protected String[] getFileIncludes()
getFileTypeExtension()
protected String[] getFileExcludes()
Each file type has a configuration property where exclude patterns can be listed. This property
key is retrieved by getExcludesConfigKey()
, and then split by the comma to get the array
of patterns
getExcludesConfigKey();
protected File getFileTypeSubDirectory()
Sub directory is formed by finding the directory with name getFileTypeDirectoryName()
within
the theme directory
getFileTypeDirectoryName()
protected File createMergedFile(boolean minified)
The merged file name is constructed by taking the theme name, concatenated with "." and the project version. To form the minified file name, the min suffix ".min" is appended to the merged file name
minified
- indicates whether to add the minified suffix
protected void mergeFiles(List<File> filesToMerge, File mergedFile) throws IOException
Contents are read for each file in the order they appear in the files list. Before adding the contents
to the merged file, the method processMergeFileContents(java.lang.String, java.io.File, java.io.File)
is invoked to allow subclasses to alter the contents
filesToMerge
- list of files whose content should be mergedmergedFile
- file that should receive the merged content
IOException
protected abstract String getFileTypeExtension()
protected abstract String getFileTypeDirectoryName()
protected abstract String getExcludesConfigKey()
protected abstract String getFileListingConfigKey()
protected abstract void addAdditionalFiles(List<File> themeFiles)
themeFiles
- list of additional files to included for the themeprotected abstract List<File> sortThemeFiles(List<File> pluginFiles, List<File> subDirFiles)
pluginFiles
- list of files that will be included and come from a plugin directorysubDirFiles
- list of files that will be included and come from the theme subdirectory
protected abstract String processMergeFileContents(String fileContents, File fileToMerge, File mergedFile) throws IOException
fileContents
- contents of the file that will be addedfileToMerge
- file the contents were pulled frommergedFile
- file receiving the merged contents
IOException
protected abstract void minify(File mergedFile, File minifiedFile) throws IOException
mergedFile
- file containing the merged contentsminifiedFile
- file created to receive the minified contents
IOException
protected List<String> getThemePropertyValue(String propertyKey)
propertyKey
- key for the property to retrieve the value for
protected List<File> getPropertyValueAsPluginDirs(String propertyKey)
propertyKey
- key for the property to retrieve the value for
protected List<File> addMissingPluginDirs(List<File> pluginList)
pluginList
- list of plugin directories to complete
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |