|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.soton.itinnovation.grid.service.utils.ConfigUtils
public class ConfigUtils
Utility class for JSP configuration pages.
| Constructor Summary | |
|---|---|
ConfigUtils(String[] propFiles)
Read a set of property files. |
|
| Method Summary | |
|---|---|
static void |
copyFile(File src,
File dest)
Deprecated. use FileUtils.copyFile(File, File) |
static String |
escapeAttribute(String attr)
Escape HTML characters & ' and " |
static String |
escapeHTML(Object object)
Escape HTML characters & and <. |
static String |
escapeTargetAttr(String value)
Escape and encode a value for use in an HTML (href) attribute. |
static String |
formatException(Throwable ex)
Escape HTML characters in exception message. |
static String |
get(Map map,
String name)
Get a property from a form submission's parameters. |
String |
get(String name)
Return the value of the property read from the files given to the constructor. |
File |
getConfigDir()
Get the configured configuration directory. |
static File |
getHibernateDatabaseDir()
Get the configured hibernate database directory or null
if it has not been configured. |
static boolean |
getNeedRestart()
|
static String |
getRealPath()
|
static String |
getRestartHint()
Convenience wrapper for getRestartHint(boolean) with mainLink = true. |
static String |
getRestartHint(boolean mainLink)
Tell the user how to restart the container. |
static String |
getServerInfo()
|
static String |
getServerName()
|
static String |
getTomcatVersion()
Get the version number of tomcat as a string. |
static String |
getWebAppName(HttpServletRequest request)
Returns the name of the webapp. |
String |
input(String name,
String value)
Convenience wrapper for input(String, String, int) when the size is unspecified. |
String |
input(String name,
String value,
int size)
Create a text input form field. |
static boolean |
isJBoss()
|
static boolean |
isTomcat()
|
static void |
setJBoss()
|
static void |
setNeedRestart()
Set a flag that can only be cleared by restarting the webapp. |
static void |
setRealPath(String rp)
Set the realPath. |
static void |
setServerInfo(String si)
Set the serverInfo String, e.g. |
static void |
setServerName(String sn)
|
static void |
setTomcat()
|
static String |
stackTrace(Throwable ex)
Format a stack trace for display in a web-admin page. |
static void |
writeConfig(File file,
String contents)
Create a file with the given contents. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConfigUtils(String[] propFiles)
throws Exception
input(java.lang.String, java.lang.String, int)
Exception| Method Detail |
|---|
public static void setNeedRestart()
public static boolean getNeedRestart()
public String get(String name)
throws Stop
Stop
public static String get(Map map,
String name)
throws Stop
map - a mapping of names to arrays of valuesname - the name of the parameter
Stop - if the parameter isn't in the map
public static void writeConfig(File file,
String contents)
throws Stop
file - the name of the file to createcontents - the contents to write. Any backslashes are escaped.
Stop - if the directory containing the file does not exist
Stop - if the file cannot be written
public String input(String name,
String value,
int size)
name - the form control's namevalue - a default value, if none was read by ConfigUtils(String[]).size - the default field size, or 0 to leave unset
public String input(String name,
String value)
input(String, String, int) when the size is unspecified.
public File getConfigDir()
public static String getRestartHint()
getRestartHint(boolean) with mainLink = true.
public static String getRestartHint(boolean mainLink)
mainLink - whether to include a 'click here to continue' link to main.jsp.
public static void copyFile(File src,
File dest)
throws Exception
FileUtils.copyFile(File, File)
Exceptionpublic static String getWebAppName(HttpServletRequest request)
public static String formatException(Throwable ex)
public static String escapeTargetAttr(String value)
escapeAttribute(java.lang.String)).
Note: By default, tomcat is configured to interpret query parameters as being encoding using iso-8859-1, but it can be configured to use other character sets by putting a "URIEncoding" attribute on the <Connector> in tomcat's configuration. Ideally, we would use this encoding but it's difficult to extract it, so we always use UTF-8 for now and you have to update your configuration manually.
value - the value to encode
public static String escapeAttribute(String attr)
attr - string to convert
public static String escapeHTML(Object object)
object - to convert to string, or null
public static String stackTrace(Throwable ex)
try {
// body of page
} catch (Throwable ex) {
out.write(ConfigUtils.stackTrace(ex));
}
ex - a throwable. A full stack trace is shown, unless ex is a Stop,
in which case only the cause (if any) is shown. Any hint from the Stop is
also displayed.
Stoppublic static void setRealPath(String rp)
public static String getRealPath()
public static void setServerInfo(String si)
public static String getServerInfo()
public static String getTomcatVersion()
null is returned
if the servlet container does not appear to be any version of tomcat.
null
if the servlet container does not appear to be tomcat, as determined
with isTomcat()isTomcat()public static void setServerName(String sn)
public static String getServerName()
public static void setTomcat()
public static boolean isTomcat()
public static void setJBoss()
public static boolean isJBoss()
public static File getHibernateDatabaseDir()
null
if it has not been configured.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||