|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.flexive.shared.FxSharedUtils
public final class FxSharedUtils
Flexive shared utility functions.
| Nested Class Summary | |
|---|---|
static class |
FxSharedUtils.AssignmentPositionSorter
Comparator for sorting Assignments according to their position. |
(package private) static class |
FxSharedUtils.AsyncStreamBuffer
Helper thread to asynchronously read and buffer an InputStream |
static class |
FxSharedUtils.BundleReference
A resource bundle reference. |
static class |
FxSharedUtils.ItemLabelSorter
Item sorter by label |
static class |
FxSharedUtils.ItemPositionSorter
Item sorter by position |
static class |
FxSharedUtils.MessageKey
Resource message key for caching |
static interface |
FxSharedUtils.ParameterMapper<K,V>
Maps keys to values. |
static class |
FxSharedUtils.ProcessResult
Helperclass holding the result of the executeCommand method |
static class |
FxSharedUtils.SelectableObjectSorter
Comparator for sorting SelectableObjectWithName instances by ID. |
static class |
FxSharedUtils.SelectableObjectWithLabelSorter
Comparator for sorting SelectableObjectWithLabel instances by label. |
static class |
FxSharedUtils.SelectableObjectWithNameSorter
Comparator for sorting SelectableObjectWithName instances by name. |
static class |
FxSharedUtils.SQLExecutor
An SQL executor, similar to ant's sql task An important addition are raw blocks: lines starting with '-- @START@' indicate the start of a raw block and lines starting with '-- @END@' indicate the end of a raw block. |
| Field Summary | |
|---|---|
static java.lang.String |
COOKIE_FORCE_TEST_DIVISION
Browser tests set this cookie to force using the test division instead of the actual division defined by the URL domain. |
static java.lang.String |
FLEXIVE_DROP_PROPERTIES
|
static java.lang.String |
FLEXIVE_STORAGE_PROPERTIES
|
static java.lang.String |
PROP_RUNONCE_MINIMAL
System property to force a minimum set of runonce scripts when set (e.g. |
static java.lang.String |
SHARED_BUNDLE
Shared message resources bundle |
static boolean |
USE_JDK6_EXTENSION
Are JDK 6+ extensions allowed to be run on the current VM? |
static boolean |
WINDOWS
|
static java.lang.String |
XPATH_ENCODEDSLASH
The character(s) representing a "xpath slash" (/) in a public URL. |
| Method Summary | ||
|---|---|---|
static java.util.List<FxSharedUtils.BundleReference> |
addMessageResources(java.lang.String baseName)
Add a resource reference for the given resource base name. |
|
static
|
checkAssignmentInherited(T assignment)
This method checks if the current assignment is a derived assignment subject to the following conditions: 1.) must be assigned to a derived type 2.) must be inherited from the derived type's parent 3.) XPaths must match |
|
static void |
checkParameterEmpty(java.lang.Object value,
java.lang.String parameterName)
Check if the given value is empty (empty string or null for String objects, empty collection, null for other objects) and throw an exception if empty. |
|
static void |
checkParameterMultilang(FxValue value,
java.lang.String paramName)
Check if the given parameter is multilingual and throw an exception if not |
|
static void |
checkParameterNull(java.lang.Object value,
java.lang.String parameterName)
Check if the given value is empty (empty string or null for String objects, empty collection, null for other objects) and throw an exception if empty. |
|
static void |
close(java.io.Closeable... resources)
Close the given resources and log a warning message if closing fails. |
|
static int |
compare(int i1,
int i2)
Primitive int comparison method (when JDK7's Integer#compare cannot be used). |
|
static int |
compare(long i1,
long i2)
Primitive long comparison method (when JDK7's Long#compare cannot be used). |
|
static java.lang.String |
decodeXPath(java.lang.String escapedXPath)
Decodes a previously escaped XPath. |
|
static java.lang.String |
escapePath(java.lang.String path)
Escape a path for usage on the current operating systems shell |
|
static java.lang.String |
escapeXPath(java.lang.String xpath)
Escapes the given XPath for use in a public URI. |
|
static FxSharedUtils.ProcessResult |
executeCommand(java.lang.String command,
java.lang.String... arguments)
Execute a command on the operating system |
|
static
|
filterSelectableObjectsById(java.lang.Iterable<T> values,
java.util.Collection<java.lang.Long> ids)
Return the elements of values that match the given ids. |
|
static
|
filterSelectableObjectsByName(java.lang.Iterable<T> values,
java.util.Collection<java.lang.String> names)
Return the elements of values that match the given names. |
|
static
|
get(java.util.Map<K,V> map,
K key,
V defaultValue)
Returns map.get(key) if key exists, defaultValue otherwise. |
|
static java.lang.String |
getApplicationServerName()
Get the name of the application server [fleXive] is running on |
|
static java.lang.String |
getBuildDate()
Get the date flexive was compiled |
|
static java.lang.String |
getBuildNumber()
Get the subversion build number |
|
static java.lang.String |
getBuildUser()
Get the name of the user that built flexive |
|
static java.lang.String |
getBundledGroovyVersion()
Get the version of the bundled groovy runtime |
|
static byte[] |
getBytes(java.lang.String s)
Returns the UTF-8 byte representation of the given string. |
|
static java.text.Collator |
getCollator()
Returns a collator for the calling user's locale. |
|
static int |
getColumnIndex(java.util.List<java.lang.String> columnNames,
java.lang.String name)
Return the index of the given column name. |
|
static int |
getColumnIndex(java.lang.String[] columnNames,
java.lang.String name)
Return the index of the given column name. |
|
static java.util.Map<java.lang.String,java.lang.String> |
getContentsFromJarStream(java.util.jar.JarInputStream jarStream,
java.lang.String searchPattern,
boolean isFile)
This method returns all entries in a JarInputStream for a given search pattern within the jar as a Map having the filename as the key and the file content as its respective value (String). |
|
static long |
getDBVersion()
Get the database version |
|
static FxDropApplication |
getDropApplication(java.lang.String name)
Returns the drop application with the given name. |
|
static java.util.List<FxDropApplication> |
getDropApplications()
Get a list of all installed and deployed drops. |
|
static java.util.List<java.lang.String> |
getDrops()
Get a list of all installed and deployed drops |
|
static java.lang.String |
getEmptyResultMessage()
Returns the localized "empty" message for empty result fields |
|
static FxString |
getEnumLabel(java.lang.Enum<?> value,
java.lang.Object... args)
Returns the localized label for the given enum value. |
|
static java.util.List<java.lang.String> |
getEnumNames(java.util.Collection<? extends java.lang.Enum> values)
Extracts the names of the given enum elements and returns them as string. |
|
static java.lang.String |
getFlexiveEdition()
Get the name of this flexive edition |
|
static java.lang.String |
getFlexiveEditionFull()
Get the name of this flexive edition with the product name |
|
static java.lang.String |
getFlexiveVersion()
Get the flexive version |
|
static java.lang.String |
getHeader()
Get the default html header title |
|
static java.lang.String |
getHostName()
Get the current hosts name |
|
static java.lang.String |
getLocalizedMessage(java.lang.String resourceBundle,
long localeId,
java.lang.String localeIso,
java.lang.String key,
java.lang.Object... args)
Get the localized message for a given language code and ISO |
|
static
|
getMappedFunction(FxSharedUtils.ParameterMapper<K,V> mapper)
Projects a single-parameter function on a hashmap. |
|
static
|
getMappedFunction(FxSharedUtils.ParameterMapper<K,V> mapper,
boolean cacheResults)
Projects a single-parameter function on a hashmap. |
|
static java.lang.String |
getMD5Sum(java.io.File file)
Calculate an MD5 checksum for a file |
|
static FxString |
getMessage(java.lang.String resourceBundle,
java.lang.String key,
java.lang.Object... args)
Returns a multilingual FxString with all translations for the given property key. |
|
static java.lang.String |
getNodeId()
|
|
static java.io.InputStream |
getResourceStream(java.lang.String name)
Get the named resource from the current thread's classloader |
|
static java.util.List<java.lang.Long> |
getSelectableObjectIdList(java.lang.Iterable<? extends SelectableObject> values)
Extract the unique IDs of the given SelectableObject collection. |
|
static long[] |
getSelectableObjectIds(java.util.Collection<? extends SelectableObject> values)
Deprecated. use getSelectableObjectIdList(Iterable) |
|
static java.util.List<java.lang.String> |
getSelectableObjectNameList(java.lang.Iterable<? extends SelectableObjectWithName> values)
Extract the unique names of the given SelectableObject collection. |
|
static java.util.List<java.lang.String> |
getStorageImplementations()
Scan all flexive storage implementations to get the name of the factory classes |
|
static java.util.Map<java.lang.String,java.lang.String> |
getStorageScriptResources(java.lang.String storageVendor)
Add all resources found in the resource subfolder for the requested vendor to the map (key=script name, value=script code) |
|
static java.util.List<java.lang.String> |
getTranslatedLocales()
Returns the list of translated locales, as specified in flexive.properties (flexive.translatedLocales). |
|
static java.util.List<StepDefinition> |
getUsedStepDefinitions(java.util.List<? extends Step> steps,
java.util.List<? extends StepDefinition> stepDefinitions)
Returns a list of all used step definitions for the given steps |
|
static java.lang.String |
hashPassword(long accountId,
java.lang.String password)
Compute the hash of the given flexive password, using the user ID. |
|
static java.lang.String |
hashPassword(long accountId,
java.lang.String loginName,
java.lang.String password)
Compute the hash of the given password according to the setting in SystemParameters.PASSWORD_SALT_METHOD (either with the user ID, or the user name). |
|
static java.lang.String |
hashPassword(java.lang.String loginName,
java.lang.String password)
Compute the hash of the given flexive password using the login name. |
|
static int |
indexOfSelectableObject(java.util.List<? extends SelectableObject> values,
long id)
Returns the index of the SelectableObject with the given ID, or -1 if none was found. |
|
static boolean |
isGroovyScript(java.lang.String name)
Is the script (most likely) a groovy script? |
|
static boolean |
isMinimalRunOnceScripts()
|
|
static boolean |
isQuoted(java.lang.String value,
char quoteChar)
Returns true if the given string value is quoted with the given character (e.g. |
|
static boolean |
isSnapshotVersion()
Returns true if this instance is a -SNAPSHOT version. |
|
static boolean |
isTranslatedLocale(java.lang.String localeIsoCode)
Returns true if the given locale is localized in the flexive application (compile-time parameter flexive.translatedLocales set in flexive.properties). |
|
static java.lang.String |
loadFile(java.io.File file)
Load the contents of a file, returning it as a String. |
|
static java.lang.String |
loadFromInputStream(java.io.InputStream in)
Load a String from an InputStream (until end of stream) |
|
static java.lang.String |
loadFromInputStream(java.io.InputStream in,
int length)
Load a String from an InputStream (until end of stream) |
|
static java.lang.String |
lookupResource(java.lang.String resourceBundle,
java.lang.String key,
java.lang.String localeIso)
Try to find a localized resource messages |
|
static java.lang.String |
readFromJarEntry(java.util.jar.JarInputStream jarStream,
java.util.jar.JarEntry entry)
Reads the content of a given entry in a Jar file (JarInputStream) and returns it as a String |
|
static java.lang.String |
sha1Hash(byte[] bytes)
Creates a SHA-1 hash for the given data and returns it in hexadecimal string encoding. |
|
static java.lang.String[] |
splitLiterals(java.lang.String text)
Splits the given comma-separated text. |
|
static java.lang.String[] |
splitLiterals(java.lang.String text,
char[] stringDelims,
char separator)
Splits the given text using separator. |
|
static boolean |
storeFile(java.lang.String contents,
java.io.File file)
Rather primitive "write String to file" helper, returns false if failed |
|
static java.lang.String |
stripQuotes(java.lang.String value,
char quoteChar)
Strips the quotes from the given string if it is quoted, otherwise it returns the input value itself. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SHARED_BUNDLE
public static final java.lang.String XPATH_ENCODEDSLASH
public static final java.lang.String COOKIE_FORCE_TEST_DIVISION
public static final boolean USE_JDK6_EXTENSION
public static final boolean WINDOWS
public static final java.lang.String FLEXIVE_DROP_PROPERTIES
public static final java.lang.String FLEXIVE_STORAGE_PROPERTIES
public static final java.lang.String PROP_RUNONCE_MINIMAL
| Method Detail |
|---|
public static java.lang.String getHostName()
public static java.lang.String getApplicationServerName()
public static java.io.InputStream getResourceStream(java.lang.String name)
name - name of the resource
public static java.util.Map<java.lang.String,java.lang.String> getContentsFromJarStream(java.util.jar.JarInputStream jarStream,
java.lang.String searchPattern,
boolean isFile)
throws java.io.IOException
jarStream - the given JarInputStreamsearchPattern - the pattern to be examined as a StringisFile - if true, the searchPattern is treated as a file name, if false, the searchPattern will be treated as a path
java.io.IOException - on I/O errors
public static java.lang.String readFromJarEntry(java.util.jar.JarInputStream jarStream,
java.util.jar.JarEntry entry)
throws java.io.IOException
jarStream - the given JarInputStreamentry - the given entry in the jar file
java.io.IOException - on errorspublic static java.util.List<java.lang.String> getDrops()
public static java.util.List<FxDropApplication> getDropApplications()
public static FxDropApplication getDropApplication(java.lang.String name)
name - the application name
public static java.util.List<java.lang.String> getStorageImplementations()
public static java.util.Map<java.lang.String,java.lang.String> getStorageScriptResources(java.lang.String storageVendor)
storageVendor - requested vendor
public static int getColumnIndex(java.lang.String[] columnNames,
java.lang.String name)
name has no
prefix (e.g. "co."), then only a suffix match is performed (e.g.
"name" matches "co.name" or "abc.name", whichever comes first.)
columnNames - all column names to be searchedname - the requested column name
public static int getColumnIndex(java.util.List<java.lang.String> columnNames,
java.lang.String name)
name has no
prefix (e.g. "co."), then only a suffix match is performed (e.g.
"name" matches "co.name" or "abc.name", whichever comes first.)
columnNames - all column names to be searchedname - the requested column name
public static java.lang.String hashPassword(long accountId,
java.lang.String password)
accountId - the user account IDpassword - the cleartext password
public static java.lang.String hashPassword(java.lang.String loginName,
java.lang.String password)
loginName - the user login namepassword - the cleartext password
public static java.lang.String hashPassword(long accountId,
java.lang.String loginName,
java.lang.String password)
SystemParameters.PASSWORD_SALT_METHOD (either with the user ID, or the user name).
accountId - the user account IDloginName - the login namepassword - the cleartext password
public static java.text.Collator getCollator()
public static boolean isGroovyScript(java.lang.String name)
name - script name to check
public static void checkParameterMultilang(FxValue value,
java.lang.String paramName)
value - the value to checkparamName - name of the parameter
public static java.lang.String sha1Hash(byte[] bytes)
throws java.security.NoSuchAlgorithmException
bytes - data to be hashed
java.security.NoSuchAlgorithmException - if the SHA-1 provider does not existpublic static java.lang.String getMD5Sum(java.io.File file)
file - file to calculate checksum for
public static FxSharedUtils.ProcessResult executeCommand(java.lang.String command,
java.lang.String... arguments)
command - name of the commandarguments - arguments to pass to the command (one argument per String!)
public static java.lang.String loadFile(java.io.File file)
file - the File to load
public static java.lang.String loadFromInputStream(java.io.InputStream in)
in - InputStream
in was null.
public static java.lang.String loadFromInputStream(java.io.InputStream in,
int length)
in - InputStreamlength - length of the string if > -1 (NOT number of bytes to read!)
in was null.
public static boolean storeFile(java.lang.String contents,
java.io.File file)
false if failed
contents - the String to storefile - the file, if existing it will be overwritten
public static java.lang.String getFlexiveVersion()
public static boolean isSnapshotVersion()
public static java.lang.String getBuildNumber()
public static long getDBVersion()
public static java.lang.String getBuildDate()
public static java.lang.String getFlexiveEdition()
public static java.lang.String getFlexiveEditionFull()
public static java.lang.String getBuildUser()
public static java.lang.String getHeader()
public static java.lang.String getBundledGroovyVersion()
public static java.lang.String getEmptyResultMessage()
public static void checkParameterNull(java.lang.Object value,
java.lang.String parameterName)
value - value to checkparameterName - name of the value (for the exception)
public static void checkParameterEmpty(java.lang.Object value,
java.lang.String parameterName)
value - value to checkparameterName - name of the value (for the exception)
public static java.lang.String lookupResource(java.lang.String resourceBundle,
java.lang.String key,
java.lang.String localeIso)
resourceBundle - the name of the resource bundle to retrieve the message fromkey - resource keylocaleIso - locale of the resource bundle
public static java.lang.String getLocalizedMessage(java.lang.String resourceBundle,
long localeId,
java.lang.String localeIso,
java.lang.String key,
java.lang.Object... args)
resourceBundle - the resource bundle to uselocaleId - used locale if args contain FxString instanceslocaleIso - ISO code of the requested localekey - the key in the resource bundleargs - arguments to replace in the message ({n})
public static boolean isTranslatedLocale(java.lang.String localeIsoCode)
localeIsoCode - the locale ISO code, e.g. "en" or "de"
public static java.util.List<java.lang.String> getTranslatedLocales()
public static FxString getMessage(java.lang.String resourceBundle,
java.lang.String key,
java.lang.Object... args)
resourceBundle - the resource bundle to be usedkey - the message keyargs - optional parameters to be replaced in the property translations
public static FxString getEnumLabel(java.lang.Enum<?> value,
java.lang.Object... args)
FQCN.value,
e.g. com.flexive.shared.search.query.ValueComparator.LIKE.
value - the enum value to be translatedargs - optional arguments to be replaced in the localized messages
public static java.util.List<StepDefinition> getUsedStepDefinitions(java.util.List<? extends Step> steps,
java.util.List<? extends StepDefinition> stepDefinitions)
steps - list of steps to be examinedstepDefinitions - all defined step definitions
public static java.lang.String[] splitLiterals(java.lang.String text,
char[] stringDelims,
char separator)
text - the text to be splittedstringDelims - delimiters for literal string values, usually ' and "separator - separator between tokens
public static java.lang.String[] splitLiterals(java.lang.String text)
text - the text to be splitted
public static <K,V> java.util.Map<K,V> getMappedFunction(FxSharedUtils.ParameterMapper<K,V> mapper)
getMappedFunction(com.flexive.shared.FxSharedUtils.ParameterMapper, boolean)
to create a caching mapper.
mapper - the parameter mapper wrapping the function to be called
public static <K,V> java.util.Map<K,V> getMappedFunction(FxSharedUtils.ParameterMapper<K,V> mapper,
boolean cacheResults)
mapper - the parameter mapper wrapping the function to be calledcacheResults - if the mapper results should be cached by the map
public static java.lang.String escapePath(java.lang.String path)
path - path to escape
public static java.lang.String escapeXPath(java.lang.String xpath)
xpath - the xpath to be escaped
decodeXPath(String)public static java.lang.String decodeXPath(java.lang.String escapedXPath)
escapedXPath - the escaped XPath
escapeXPath(String)
public static <K,V> V get(java.util.Map<K,V> map,
K key,
V defaultValue)
map.get(key) if key exists, defaultValue otherwise.
map - a mapkey - the required keydefaultValue - the default value to be returned if key does not exist in map
map.get(key) if key exists, defaultValue otherwise.
public static boolean isQuoted(java.lang.String value,
char quoteChar)
value - the string value to be checkedquoteChar - the quote character, for example '
public static java.lang.String stripQuotes(java.lang.String value,
char quoteChar)
value - the value to be "unquoted"quoteChar - the quote character, for example '
value, if it was not quotedpublic static byte[] getBytes(java.lang.String s)
String.getBytes(), since the latter will fail if the system locale is not UTF-8.
s - the string to be processed
public static java.util.List<java.lang.String> getEnumNames(java.util.Collection<? extends java.lang.Enum> values)
values - the enum values
@Deprecated public static long[] getSelectableObjectIds(java.util.Collection<? extends SelectableObject> values)
getSelectableObjectIdList(Iterable)
SelectableObject collection.
values - the input values
public static java.util.List<java.lang.Long> getSelectableObjectIdList(java.lang.Iterable<? extends SelectableObject> values)
SelectableObject collection.
values - the input values
public static java.util.List<java.lang.String> getSelectableObjectNameList(java.lang.Iterable<? extends SelectableObjectWithName> values)
SelectableObject collection.
values - the input values
public static int indexOfSelectableObject(java.util.List<? extends SelectableObject> values,
long id)
SelectableObject with the given ID, or -1 if none was found.
values - the values to be examinedid - the target ID
SelectableObject with the given ID, or -1 if none was found.
public static <T extends SelectableObject> java.util.List<T> filterSelectableObjectsById(java.lang.Iterable<T> values,
java.util.Collection<java.lang.Long> ids)
values that match the given ids.
T - the value typevalues - the values to be searchids - the required IDs
values that match the given ids.
public static <T extends SelectableObjectWithName> java.util.List<T> filterSelectableObjectsByName(java.lang.Iterable<T> values,
java.util.Collection<java.lang.String> names)
values that match the given names.
T - the value typevalues - the values to be searchnames - the required IDs
values that match the given names.
public static int compare(int i1,
int i2)
NumberUtils.
i1 - the first valuei2 - the second value
Integer.compareTo(java.lang.Integer)
public static int compare(long i1,
long i2)
NumberUtils.
i1 - the first valuei2 - the second value
Integer.compareTo(java.lang.Integer)
public static java.util.List<FxSharedUtils.BundleReference> addMessageResources(java.lang.String baseName)
throws java.io.IOException
baseName - the resource name (e.g. "ApplicationResources")
java.io.IOException - if an I/O error occured while looking for resourcespublic static void close(java.io.Closeable... resources)
resources - the resource(s) to be closedpublic static boolean isMinimalRunOnceScripts()
PROP_RUNONCE_MINIMALpublic static <T extends FxAssignment> boolean checkAssignmentInherited(T assignment)
T - extends FxAssignmentassignment - an FxAssignment
public static java.lang.String getNodeId()
NodeConfigurationEngine.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||