Package nl.gx.webmanager.wcb.lifecycle
Class WCBLifecycleUtil
- java.lang.Object
-
- nl.gx.webmanager.wcb.lifecycle.WCBLifecycleUtil
-
public class WCBLifecycleUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description WCBLifecycleUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
deleteExcludedBundleResources(org.osgi.framework.Bundle bundle, String srcFileNamePrefix, String destFileNamePrefix, String directoryName)
Deletes all the resources (files and directories) that are in the directory, but not in the resources of the bundle.static void
deleteFileFromDisk(File file)
Deletes a specified file from disk.static String
formatFileName(String fileName)
Formats the specified filename by fixing \ and / file separators and removing the starting file separator.static String
formatFileName(String fileName, Boolean cutStartingSeparator)
Formats the specified filename by fixing \ and / file separators.static String
formatPath(String pathName)
Ensure that the given pathname is a system path; System specific direcory indicators and ending with File.separator.static ComponentBundleDefinition
getBundleDefinition(org.osgi.framework.Bundle bundle)
Returns the component bundle definition from the specified bundle.
If the given bundle does not provide any component bundle definitionnull
will be returned.static String
substringAfter(String str, String separator)
Returns the remainder of the string after the first occurrence of the given separator.static void
writeBundleResourcesToFile(String[] srcFileNames, String jarScrPrefix, String destFileNamePrefix, ComponentBundleDefinition bundleDefinition, String baseDir)
Deploys the srcFileNames[] to the given destFileNamePrefix.static void
writeBundleResourcesToFile(String srcFileNamePrefix, String destFileNamePrefix, String baseDirectory, ComponentBundleDefinition bundleDefinition)
static void
writeComponentBundleResourceToFile(String srcFileName, String destFileName, String destFileNamePrefix, String destBaseDirectory, ComponentBundleDefinition bundleDefinition)
Writes component bundle resource to file, where the source file is a file contained by the OSGi bundlestatic void
writeComponentBundleResourceToFile(FileResource srcFile, String destFileName, String destFileNamePrefix, String destBaseDirectory)
Writes a component bundle resource to a file, where the source file is passes as a FileResource object.static void
writeResourceToFile(InputStream resourceStream, String destFileName)
Stream a resource file named resourceName, which is present in the bundle that is passed on, to the specified location.static void
writeResourceToFile(URL srcResourceURL, String destFileName)
Stream a resource file named resourceName, which is present in the bundle that is passed on, to the specified location.
-
-
-
Method Detail
-
deleteFileFromDisk
public static void deleteFileFromDisk(File file)
Deletes a specified file from disk.- Parameters:
file
- File to delete
-
deleteExcludedBundleResources
public static void deleteExcludedBundleResources(org.osgi.framework.Bundle bundle, String srcFileNamePrefix, String destFileNamePrefix, String directoryName)
Deletes all the resources (files and directories) that are in the directory, but not in the resources of the bundle.- Parameters:
bundle
- The bundle that contains the resources to compare withdirectoryName
- The directory to check for resourcessrcFileNamePrefix
- The prefix of files in the bundle, like "presentationtype/jsp/"destFileNamePrefix
- The prefix of files in the directory, like "WEB-INF/project/<bundleId>"
-
writeBundleResourcesToFile
public static void writeBundleResourcesToFile(String srcFileNamePrefix, String destFileNamePrefix, String baseDirectory, ComponentBundleDefinition bundleDefinition)
- Parameters:
srcFileNamePrefix
-destFileNamePrefix
-baseDirectory
-
-
writeBundleResourcesToFile
public static void writeBundleResourcesToFile(String[] srcFileNames, String jarScrPrefix, String destFileNamePrefix, ComponentBundleDefinition bundleDefinition, String baseDir)
Deploys the srcFileNames[] to the given destFileNamePrefix. Typically used for language resources f.e. jar file : messages/messages_nl_nl.properties which will be deployed as : /WEB-INF/messages/{bundle_id}_nl_nl.properties- Parameters:
srcFileNames
- filenames to deploy (jar format)jarScrPrefix
- prefix for the srcFileNames location in the jar f.e. messages/destFileNamePrefix
- destination path can hold bundle specific names
-
writeComponentBundleResourceToFile
public static void writeComponentBundleResourceToFile(String srcFileName, String destFileName, String destFileNamePrefix, String destBaseDirectory, ComponentBundleDefinition bundleDefinition)
Writes component bundle resource to file, where the source file is a file contained by the OSGi bundle- Parameters:
srcFileName
- The source file to write, passed as the name of the file as is occurs in the bundledestFileName
- The destination file name (without path)destFileNamePrefix
- The prefix to append to the destination file namedestBaseDirectory
- The directory to write the destination file to
-
writeComponentBundleResourceToFile
public static void writeComponentBundleResourceToFile(FileResource srcFile, String destFileName, String destFileNamePrefix, String destBaseDirectory)
Writes a component bundle resource to a file, where the source file is passes as a FileResource object.- Parameters:
srcFile
- The source file to write, as a FileResourcedestFileName
- The destination file name (without path)destFileNamePrefix
- The prefix to append to the destination file namedestBaseDirectory
- The directory to write the destination file to
-
writeResourceToFile
public static void writeResourceToFile(URL srcResourceURL, String destFileName)
Stream a resource file named resourceName, which is present in the bundle that is passed on, to the specified location.- Parameters:
srcResourceURL
- URL of resource to writedestFileName
- Destination filename to write to
-
writeResourceToFile
public static void writeResourceToFile(InputStream resourceStream, String destFileName)
Stream a resource file named resourceName, which is present in the bundle that is passed on, to the specified location.- Parameters:
resourceStream
- InputStream of resource to writedestFileName
- Destination filename to write to
-
substringAfter
public static String substringAfter(String str, String separator)
Returns the remainder of the string after the first occurrence of the given separator.- Parameters:
str
- String to evaluateseparator
- Separator to split on- Returns:
- remainder of the string after the first occurrence of the given separator
-
formatFileName
public static String formatFileName(String fileName)
Formats the specified filename by fixing \ and / file separators and removing the starting file separator.- Parameters:
fileName
- Filename to format is removed from the filename- Returns:
- Formatted filename
-
formatFileName
public static String formatFileName(String fileName, Boolean cutStartingSeparator)
Formats the specified filename by fixing \ and / file separators.- Parameters:
fileName
- Filename to formatcutStartingSeparator
- iftrue
the starting separator is removed from the filename- Returns:
- Formatted filename
-
formatPath
public static String formatPath(String pathName)
Ensure that the given pathname is a system path; System specific direcory indicators and ending with File.separator.- Parameters:
pathName
-- Returns:
- pathName as a path
-
getBundleDefinition
public static ComponentBundleDefinition getBundleDefinition(org.osgi.framework.Bundle bundle)
Returns the component bundle definition from the specified bundle.
If the given bundle does not provide any component bundle definitionnull
will be returned.- Parameters:
bundle
- Bundle to retrieve the component bundle definition for.- Returns:
- ComponentBundleDefinition for the specified bundle or
null
if the given bundle does not provide any.
-
-