|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.drupal.project.async_command.DrupletUtils
public final class DrupletUtils
A group of useful tools to help with Druplet apps. Note: You can potentially run any Drupal API using executeDrush() with "drush eval". Make sure you have a local copy of Drupal, and set its database to the Drupal database you try to connect to.
Field Summary | |
---|---|
static java.lang.String |
VERSION
Version string to keep track of jar changes. |
Constructor Summary | |
---|---|
DrupletUtils()
|
Method Summary | |
---|---|
static java.lang.String |
convertBlobToString(java.lang.Object blobValue)
Convert the byte[] blog value from this.queryValue() to a string. |
static java.util.Properties |
convertSettingsToConfig(java.io.File settingsFile)
Make config properties out of Drupal settings.php. |
static byte[] |
convertStringToBlob(java.lang.String stringValue)
Convert a String to a byte[] used for database blob. |
static java.lang.String |
evalPhp(java.lang.String phpCode)
Evaluates PHP code and return the output. |
static java.lang.String |
evalPhp(java.lang.String pattern,
java.lang.Object... params)
Execute PHP using substitutes. |
static java.lang.String |
executeDrush(java.lang.String... vars)
Execute drush using the given parameters. |
static java.lang.String |
executeSystemCommand(java.util.List<java.lang.String> command,
java.io.File workingDir)
Execute a command in the working dir, and return the output as a String. |
static java.io.File |
getConfigPropertiesFile()
Find the config.properties file under various locations. |
static java.lang.String |
getContent(java.io.Reader input)
From the input reader and get all its content. |
static java.io.File |
getDrupalSettingsFile()
Try to get Drupal's settings.php file in various locations. |
static java.lang.String |
getIdentifier(java.lang.Class<?> classObject)
Get either the identifier if presented, or the class name. |
static long |
getLocalUnixTimestamp()
Get the unix timestamp of the local server. |
static java.lang.Long |
getLong(java.lang.Object value)
Get the long value from any Object, if possible. |
static java.util.logging.Logger |
getPackageLogger()
|
static java.util.Properties |
loadConfig()
Helper function to try to locate either config.properties or settings.php to establish Druplet or DrupalConnection. |
static java.util.Properties |
loadProperties(java.io.File configFile)
Helper function to load properties from a config file. |
static java.util.Properties |
loadProperties(java.lang.String configString)
Helper function to load properties from a String. |
static void |
prepareConfig(java.util.Properties config)
Prepare config properties, e.g. |
static java.lang.Object |
unserializePhp(java.lang.String serialized)
Unserialize any PHP variable. |
static java.util.Map<java.lang.String,java.lang.Object> |
unserializePhpArray(java.lang.String serialized)
Unserialize PHP array string |
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 VERSION
Constructor Detail |
---|
public DrupletUtils()
Method Detail |
---|
public static java.util.logging.Logger getPackageLogger()
public static java.lang.String evalPhp(java.lang.String phpCode)
phpCode
- PHP code snippet.
public static java.lang.String evalPhp(java.lang.String pattern, java.lang.Object... params)
pattern
- PHP code patternparams
- Values to insert into the PHP code pattern
MessageFormat
public static java.util.Map<java.lang.String,java.lang.Object> unserializePhpArray(java.lang.String serialized)
serialized
- The string of the PHP serialized array
public static java.lang.Object unserializePhp(java.lang.String serialized)
serialized
- The string of the PHP serialized array
SerializedPhpParser
public static java.lang.String getContent(java.io.Reader input) throws java.io.IOException
input
- input reader
java.io.IOException
public static java.lang.String convertBlobToString(java.lang.Object blobValue)
blobValue
- a byte[] array
public static byte[] convertStringToBlob(java.lang.String stringValue)
stringValue
-
public static java.io.File getDrupalSettingsFile() throws java.io.FileNotFoundException
java.io.FileNotFoundException
public static java.io.File getConfigPropertiesFile() throws java.io.FileNotFoundException
java.io.FileNotFoundException
public static void prepareConfig(java.util.Properties config)
config
- The original, un-prepared config (will be prepared after execution)public static java.util.Properties convertSettingsToConfig(java.io.File settingsFile)
getDrupalSettingsFile()
to locate settings.php.
Often, you need to run prepareConfig(java.util.Properties)
to further process the config. This method only does the raw conversion.
settingsFile
- The settings.php file
public static java.util.Properties loadConfig()
public static java.util.Properties loadProperties(java.lang.String configString)
configString
-
public static java.util.Properties loadProperties(java.io.File configFile)
configFile
-
public static long getLocalUnixTimestamp()
public static java.lang.Long getLong(java.lang.Object value)
value
- The object that could either be null, or int, or string.
public static java.lang.String executeDrush(java.lang.String... vars)
vars
- Parameters for the drush execution.
public static java.lang.String executeSystemCommand(java.util.List<java.lang.String> command, java.io.File workingDir)
command
- The list of command and parameters.workingDir
- The working directory. Could be null. The it's default user.dir.
public static java.lang.String getIdentifier(java.lang.Class<?> classObject)
classObject
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |