com.novell.emframe.dev
Class eMFrameUtils

java.lang.Object
  extended bycom.novell.emframe.dev.eMFrameUtils

public class eMFrameUtils
extends java.lang.Object

General utility methods for use by plug-ins. Methods help with localization and web development. Most methods are static.

The main methods to use to access objects your task may need:


Constructor Summary
eMFrameUtils()
           
 
Method Summary
static void addUnique(java.util.Collection collection, java.util.Collection newItems)
          Adds all newItems to Collection if they don't exist.
static void addUnique(java.util.Collection dstCollection, java.lang.Object[] sourceObjects)
          Adds all sourceObjects to dstCollection if they don't exist.
static int byteToDecimal(byte b)
          Converts a byte to its positive decimal value.
static java.lang.String concatProperties(java.util.Properties properties)
          Creates semi-colon delimited key/value pair string.
static java.lang.String concatStrings(java.lang.String[] strings, java.lang.String delimiter)
          Concatinates tokens together seperated by delimiter.
static java.lang.Throwable discoverRootException(java.lang.Throwable ex)
          If the exception is a org.apache.jasper.JasperException, it finds the root cause.
static java.lang.String formatMessage(java.lang.String pattern, java.lang.Object[] arguments)
          Convenience method that works just like MessageFormat.formatMessage(), but first replaces all occurences of ' with ''.
static java.lang.String getAccessMode(TaskContext context)
          Returns the current mode of Role-based services ("Unrestricted", "CollectionOwner", or "Assigned").
static byte[] getByteArray(java.io.InputStream is)
          Reads in all of the input stream and retuns it as a byte[].
static java.lang.String getClassName(org.jdom.Document doc)
          Inspects plug-in XML descriptor and returns Java class entry point.
static java.lang.String getConfigSetting(com.novell.nps.gadgetManager.BaseGadgetInstance task, java.lang.String prop, java.lang.String defaultValue)
          Returns the value of a configuration setting as a String, or a default value if the setting does not exist.
static java.lang.String[] getConfigSettings(com.novell.nps.gadgetManager.BaseGadgetInstance task, java.lang.String prop)
          Returns the values of a configuration setting as an array of Strings.
static java.lang.String getDisplayName(org.jdom.Document taskDoc, PluginContext context)
          Gets the display name of an iManager plug-in from the XML descriptor.
static java.lang.String getDisplayName(org.jdom.Element root, PluginContext context)
          Gets the display name of an iManager plug-in from the XML descriptor.
static java.lang.String getDisplayName(org.jdom.Element root, java.lang.String tagName, PluginContext context)
          Gets the display name of an iManager plug-in from the XML descriptor and passes in the tag name to use to get the display-name key.
static java.lang.String getErrorTemplate(PluginContext context)
          Gets the simple name of the error JSP to be used for rendering.
static java.lang.String getExceptionMessage(java.lang.Exception e, PluginContext context)
          Inspects the exception and creates the best message it can (based on the type of exception).
static java.lang.String getLocalizedString(java.lang.String strResourceFile, java.lang.String strResId, java.util.Locale locale)
          Gets a localized String from a resource file.
static java.lang.String getLocalizedString(java.lang.String strResourceFile, java.lang.String strResId, PluginContext context)
          Gets a localized String from a resource file.
static java.lang.String getMergeTemplate(PluginContext context)
          Gets the simple name of the merge JSP to be used for rendering.
static java.lang.String getModuleFromFullName(java.lang.String fullName)
          From a full jsp resource name (ex.
static java.lang.String getModulesBasePath()
          Gets a filesystem dependant full path to the modules directory.
static java.lang.String getPageFromFullName(java.lang.String fullName)
          From a full jsp resource name (ex.
static java.lang.String getPersistentData(java.lang.String keyId, TaskContext context)
          Reads data from persistent store.
static java.lang.String getRBSExceptionLocalizedString(com.novell.rbs.RBSException ex, PluginContext context)
          Inspects an RBSException and creates localized error message.
static java.lang.String getRealPath(java.lang.String relativeURL)
          Gets the full path from a path relative to our webapp.
static java.lang.String getSingleTarget(javax.servlet.http.HttpServletRequest request)
          When using the TargetChooser widget (TC), this method returns the name of the object selected by the user.
static java.lang.String getUniqueString(java.lang.String prefix, java.lang.String postfix)
          Simply creates a string that is guarenteed to be unique.
static java.util.Properties getUrlParams(org.jdom.Document doc)
          Allows easy access to URL params stored in plug-in XML descriptor.
static java.util.Properties getUrlParamsAsProperties(org.jdom.Document doc)
          Allows easy access to URL params stored in plug-in XML descriptor.
static byte[] hexStringToByteArray(java.lang.String str)
          Converts a string to a byte array.
static boolean instanceOf(java.lang.String className, java.lang.Class c)
          Checks if the className Class is an instance of class c.
static boolean isMS55(javax.servlet.http.HttpServletRequest req)
          Checks to see if client device is Microsoft Internet Explorer 5.5 using the "User-Agent" string.
static boolean isNN6(javax.servlet.http.HttpServletRequest req)
          Checks to see if client device is Netscape Navigator 6 using the "User-Agent" string.
static boolean isPalm(javax.servlet.http.HttpServletRequest req)
          Checks to see if client device is a Palm Pilot using the "User-Agent" string.
static boolean isTaskAssigned(java.lang.String taskId, TaskContext context)
          Checks if the user has access to the specified task.
static java.lang.String join(java.util.Collection collection)
          Concatenates Strings in a Collection together separated with a "," delimiter.
static java.lang.String join(java.util.Collection collection, java.lang.String delimiter)
          Concatenates Strings in a Collection together separated with a delimiter.
static org.w3c.dom.Document newDocument()
          Instanciates an empty org.w3c.Document.
static void out(org.w3c.dom.Document doc)
          Deprecated. As of iManager 2.5. Will be removed. Use D.log(org.w3c.dom.Document doc)
static java.lang.String pack(java.lang.String[] list, PluginContext context)
          Packs a String array into one string.
static java.lang.String pack(java.lang.String value1, java.lang.String value2, PluginContext context)
          Packs a pair of strings into one string.
static java.util.Properties parseParameters(java.lang.String params)
          Parses a semi-colon delimited string of key/value pairs (ex.
static java.util.Properties parseParameters(java.lang.String params, java.lang.String delimiter)
          Parses a delimited string of key/value pairs.
static java.util.HashMap parseParameters2(java.lang.String params)
          Parses a semi-colon delimited string of key/value pairs (ex.
static void refreshOV(PluginContext context)
          Tasks that delete or created object should call this to ensure the object view is refreshed.
static void refreshResourceFileMap(java.lang.String map)
          Refreshes the filemap.
static java.lang.String replaceSubString(java.lang.String source, java.lang.String fromSubString, java.lang.String toSubString)
          Simple string replacement method.
static java.lang.String replaceWith(java.lang.String strOrig, java.lang.String strFind, java.lang.String strReplace)
          Simple string replacement method.
static byte[] reverseBytes(byte[] bytes)
          Reverses a byte array.
static void setErrorMessage(java.lang.Throwable t, TaskContext context)
          Sets the error information in the results for the current request.
static void setErrorTemplate(PluginContext context, java.lang.String template)
          Sets the JSP file to be used for rendering of response if Task.execute returns false.
static void setMergeTemplate(PluginContext context, java.lang.String template)
          Sets the JSP file to be used for rendering of response.
static void setMessage(java.lang.String messageMode, java.lang.String title, java.lang.String plainText, java.lang.String boldText, java.lang.String errorDetails, TaskContext context)
          Sets error/success message with plain and bold text as well as error details.
static void setMessage(java.lang.String messageMode, java.lang.String title, java.lang.String plainText, java.lang.String boldText, TaskContext context)
          Sets error/success message with plain and bold text.
static void setMessage(java.lang.String messageMode, java.lang.String title, java.lang.String body, TaskContext context)
          Sets error/success message.
static void setMooErrorMessage(java.util.Properties resultStrings, java.lang.String header, java.lang.String body, java.util.ArrayList errors)
          Sets the error messages for a Multiple Object Operation.
static void setPersistentData(java.lang.String keyId, java.lang.String data, TaskContext context)
          Sets the key and data in the user's persistent store.
static void setupTargetChooser(java.lang.String[] objectTypeNames, TaskContext context)
          Must be called during the server side processing on the request before the TargetChooser widget is used.
static void setupTargetChooser(TaskContext context, java.util.Properties resultStrings, java.lang.String[] objectTypeNames)
          Deprecated. use setupTargetChooser( context, objectTypeNames )
static void sortKeyValues(java.util.ArrayList keys, java.util.ArrayList values, TaskContext context)
          Takes two String ArrayLists, keys and values, and sorts the keys array moving the values in the value array to corresponding index positions.
static void sortStringArray(java.lang.String[] myArray)
          Sorts a String array while ignoring case.
static java.lang.String[] split(java.lang.String s, java.lang.String delimiter)
          Tokenize a string into a String array of tokens.
static java.lang.String toDisplay(java.lang.String strText)
          Method to escape string for use in HTML.
static java.lang.String toHexString(byte[] bytes)
          Converts a byte array to a hex string.
static java.util.Vector tokenize(java.lang.String params, java.lang.String delimiter)
          Tokenize a string into a Vector of tokens.
static java.lang.String toOSFilterString(java.lang.String[] types)
          Creates a String that can be used as an ObjectSelector filter string.
static java.lang.String toScript(java.lang.String strText)
          Escapes the characters single quote ('), double quote ("), backslash (\) by inserting a backslash before each occurance.
static java.lang.String toTag(java.lang.String str)
          Escapes chars for use in HTML tags.
static java.lang.String trimQuotes(java.lang.String str)
          Removes the leading and trailing quotes from a String object.
static java.lang.String[] unpack(java.lang.String s, PluginContext context)
          Unpacks data packed with the pack routine.
static java.lang.String urlDecode(java.lang.String s, PluginContext context)
          Decodes String that has been urlEncoded.
static java.lang.String urlDecode(java.lang.String s, java.lang.String encoding)
          Decodes string that has been urlEncoded.
static java.lang.String urlEncode(java.lang.String strText)
          URL encodes using utf-8 encoding.
static java.lang.String urlEncode(java.lang.String s, PluginContext context)
          Encodes URL for strings.
static java.lang.String urlEncode(java.lang.String strText, java.lang.String charset)
          Encodes all characters except 0-9, A-Z, and a-z.
static java.lang.String urlEncodePath(java.lang.String strText)
          Encodes all characters except 0-9, A-Z, and a-z and '/'.
static java.lang.String urlEncodePath(java.lang.String strText, java.lang.String charset)
          Encodes all characters except 0-9, A-Z, and a-z and '/'.
static java.lang.String xmlDecode(java.lang.String str)
          Decodes string that has been escape for XML.
static java.lang.String xmlEncode(java.lang.String strText)
          Escapes chars for use in XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

eMFrameUtils

public eMFrameUtils()
Method Detail

addUnique

public static void addUnique(java.util.Collection collection,
                             java.util.Collection newItems)
Adds all newItems to Collection if they don't exist.

Parameters:
collection - Collection to be added to
newItems - Collection to add to the existing collection

addUnique

public static void addUnique(java.util.Collection dstCollection,
                             java.lang.Object[] sourceObjects)
Adds all sourceObjects to dstCollection if they don't exist.

Parameters:
dstCollection - Collection to be added to
sourceObjects - Object array to add to Collection

byteToDecimal

public static final int byteToDecimal(byte b)
Converts a byte to its positive decimal value.

Parameters:
b - byte to convert
Returns:
A positive int which represents the byte argument

concatProperties

public static final java.lang.String concatProperties(java.util.Properties properties)
Creates semi-colon delimited key/value pair string.

Parameters:
properties - Properties object containing all key/value pairs
Returns:
String delimited by semi-colons containing the key/value pairs (ex. "key1=val1;key2=val2")

concatStrings

public static final java.lang.String concatStrings(java.lang.String[] strings,
                                                   java.lang.String delimiter)
Concatinates tokens together seperated by delimiter.

Parameters:
strings - String array of tokens
delimiter - String containing the delimiter between tokens (ex. ".")
Returns:
String made from concatenation the tokens and the delimiter (ex. "token1.token2.token3")

discoverRootException

public static java.lang.Throwable discoverRootException(java.lang.Throwable ex)
If the exception is a org.apache.jasper.JasperException, it finds the root cause.

Parameters:
ex - org.apache.jasper.JasperException that wrappers a real exception
Returns:
Throwable containing the root cause of the exception

formatMessage

public static java.lang.String formatMessage(java.lang.String pattern,
                                             java.lang.Object[] arguments)
Convenience method that works just like MessageFormat.formatMessage(), but first replaces all occurences of ' with ''. This is because MessageFormat.formatMessage() treats the single quote special, using it to quote curly braces. It will remove all single quotes and changes two single quotes to one. Use this method when you do not want the single quote treated differently.

Parameters:
pattern - String to format
arguments - Object array to pass to MessageFormat.format()
Returns:
String containing the formated message

getAccessMode

public static final java.lang.String getAccessMode(TaskContext context)
Returns the current mode of Role-based services ("Unrestricted", "CollectionOwner", or "Assigned").

Parameters:
context - TaskContext of the plug-in
Returns:
String naming the current logged in users RBS mode

getByteArray

public static final byte[] getByteArray(java.io.InputStream is)
                                 throws java.io.IOException
Reads in all of the input stream and retuns it as a byte[].

Parameters:
is - InputStream to read
Returns:
all the bytes from the input stream
Throws:
java.io.IOException

getClassName

public static final java.lang.String getClassName(org.jdom.Document doc)
Inspects plug-in XML descriptor and returns Java class entry point.

Parameters:
doc - XML Document describing the plug-in
Returns:
String containing the Java class

getConfigSetting

public static java.lang.String getConfigSetting(com.novell.nps.gadgetManager.BaseGadgetInstance task,
                                                java.lang.String prop,
                                                java.lang.String defaultValue)
Returns the value of a configuration setting as a String, or a default value if the setting does not exist. If the setting is multi-valued, only the first value is returned.

Parameters:
task - BaseGadgetInstance of the task trying to get the setting
prop - String containing the name of the configuration setting
defaultValue - String containing the dafault value to return if prop is not found
Returns:
String containing the value of the configuration setting

getConfigSettings

public static java.lang.String[] getConfigSettings(com.novell.nps.gadgetManager.BaseGadgetInstance task,
                                                   java.lang.String prop)
Returns the values of a configuration setting as an array of Strings.

Parameters:
task - BaseGadgetInstance of the task trying to get the setting
prop - String containing the name of the configuration setting
Returns:
String array containing the values of the configuration setting

getDisplayName

public static final java.lang.String getDisplayName(org.jdom.Document taskDoc,
                                                    PluginContext context)
Gets the display name of an iManager plug-in from the XML descriptor.

Parameters:
taskDoc - XML Document containing the task descriptor
context - PluginContext of the plug-in
Returns:
String containing the localized plug-in display name

getDisplayName

public static final java.lang.String getDisplayName(org.jdom.Element root,
                                                    PluginContext context)
Gets the display name of an iManager plug-in from the XML descriptor.

Parameters:
root - XML Element containing the task descriptor
context - PluginContext of the plug-in
Returns:
String containing the localized plug-in display name

getDisplayName

public static final java.lang.String getDisplayName(org.jdom.Element root,
                                                    java.lang.String tagName,
                                                    PluginContext context)
Gets the display name of an iManager plug-in from the XML descriptor and passes in the tag name to use to get the display-name key.

Parameters:
root - XML Element containing the task descriptor
tagName - name of tag containing key into properties file
context - PluginContext of the plug-in
Returns:
String containing the localized plug-in display name

getErrorTemplate

public static java.lang.String getErrorTemplate(PluginContext context)
Gets the simple name of the error JSP to be used for rendering.

Parameters:
context - PluginContext of the plug-in
Returns:
String containing the "error" parameter on the HttpServletRequest
See Also:
setErrorTemplate(com.novell.emframe.dev.PluginContext, java.lang.String)

getExceptionMessage

public static final java.lang.String getExceptionMessage(java.lang.Exception e,
                                                         PluginContext context)
Inspects the exception and creates the best message it can (based on the type of exception).

Parameters:
e - Exception to get a message for
context - PluginContext of the plug-in
Returns:
String containing the exception message

getLocalizedString

public static final java.lang.String getLocalizedString(java.lang.String strResourceFile,
                                                        java.lang.String strResId,
                                                        java.util.Locale locale)
Gets a localized String from a resource file.

Parameters:
strResourceFile - String containing the base name of the resource containing the localized string. This is the name without the language (e.g. _en) specifier at the end.
strResId - String containing the key name in the resource file whose localized value is to be returned.
locale - The current locale for the user
Returns:
String containing the localized value for the string

getLocalizedString

public static final java.lang.String getLocalizedString(java.lang.String strResourceFile,
                                                        java.lang.String strResId,
                                                        PluginContext context)
Gets a localized String from a resource file.

Parameters:
strResourceFile - String containing the base name of the resource containing the localized string. This is the name without the language (e.g. _en) specifier at the end.
strResId - String containing the key name in the resource file whose localized value is to be returned.
context - PluginContext of the plug-in
Returns:
String containing the localized value for the string

getMergeTemplate

public static java.lang.String getMergeTemplate(PluginContext context)
Gets the simple name of the merge JSP to be used for rendering.

Parameters:
context - PluginContext of the plug-in
Returns:
String containing the "merge" parameter on the HttpServletRequest
See Also:
setMergeTemplate(com.novell.emframe.dev.PluginContext, java.lang.String)

getModuleFromFullName

public static final java.lang.String getModuleFromFullName(java.lang.String fullName)
From a full jsp resource name (ex. "base/MyJsp.jsp"), extracts the moduleId part(ex. "base").

Parameters:
fullName - String containing the module and jsp path (ex. "base/MyJsp.jsp")
Returns:
String containing the moduleId part (ex. "base")

getModulesBasePath

public static java.lang.String getModulesBasePath()
Gets a filesystem dependant full path to the modules directory.

Returns:
String path (ex. "c:\tomcat\webapps\nps\portal\modules")

getPageFromFullName

public static final java.lang.String getPageFromFullName(java.lang.String fullName)
From a full jsp resource name (ex. "base/MyJsp.jsp"), extracts the page part(ex. "MyJsp.jsp").

Parameters:
fullName - String containing the module and jsp path (ex. "base/MyJsp.jsp")
Returns:
String containing the page part (ex. "MyJsp.jsp")

getPersistentData

public static java.lang.String getPersistentData(java.lang.String keyId,
                                                 TaskContext context)
Reads data from persistent store. Implements sesssion caching so reads do not need to read directly from the data store.

Parameters:
keyId - String containing the key
context - TaskContext of the plug-in
Returns:
String containing the value data
See Also:
setPersistentData(java.lang.String, java.lang.String, com.novell.emframe.dev.TaskContext)

getRBSExceptionLocalizedString

public static final java.lang.String getRBSExceptionLocalizedString(com.novell.rbs.RBSException ex,
                                                                    PluginContext context)
Inspects an RBSException and creates localized error message.

Parameters:
ex - the Exception
context - PluginContext of the plug-in
Returns:
String containing the localized error message

getRealPath

public static java.lang.String getRealPath(java.lang.String relativeURL)
Gets the full path from a path relative to our webapp.

Parameters:
relativeURL - String containing the relative URL (ex. "/")
Returns:
String containing the full path (ex. "c:\tomcat\webapps\nps")

getSingleTarget

public static final java.lang.String getSingleTarget(javax.servlet.http.HttpServletRequest request)
When using the TargetChooser widget (TC), this method returns the name of the object selected by the user.

Parameters:
request - HttpServletRequest containing posted data from the target chooser
Returns:
String containing the DN name entered by the user

getUniqueString

public static final java.lang.String getUniqueString(java.lang.String prefix,
                                                     java.lang.String postfix)
Simply creates a string that is guarenteed to be unique.

Parameters:
prefix - String containing the prefix
postfix - String containing the postfix
Returns:
String containing prefix+uniquepart+postfix

getUrlParams

public static final java.util.Properties getUrlParams(org.jdom.Document doc)
Allows easy access to URL params stored in plug-in XML descriptor.

Parameters:
doc - XML Document containing the plug-in descriptor
Returns:
Properties containing keys and values

getUrlParamsAsProperties

public static final java.util.Properties getUrlParamsAsProperties(org.jdom.Document doc)
Allows easy access to URL params stored in plug-in XML descriptor.

Parameters:
doc - XML Document containing the plug-in descriptor
Returns:
Properties containing keys and values

hexStringToByteArray

public static final byte[] hexStringToByteArray(java.lang.String str)
                                         throws java.lang.NumberFormatException
Converts a string to a byte array.

The string is parsed such that each character represents a single nibble in the byte array. Valid characters are [0-9a-fA-F].

Parameters:
str - String which is parsed
Returns:
new byte array containing characters in the String
Throws:
java.lang.NumberFormatException

instanceOf

public static final boolean instanceOf(java.lang.String className,
                                       java.lang.Class c)
Checks if the className Class is an instance of class c.

Parameters:
className - String containing class name
c - Class object to check if is an instance of className
Returns:
boolean: true if className is of type c or derived type, false if otherwise

isMS55

public static boolean isMS55(javax.servlet.http.HttpServletRequest req)
Checks to see if client device is Microsoft Internet Explorer 5.5 using the "User-Agent" string.

Parameters:
req - HttpServletRequest
Returns:
boolean: true if the client device is Microsoft Internet Explorer 5.5, false if otherwise

isNN6

public static boolean isNN6(javax.servlet.http.HttpServletRequest req)
Checks to see if client device is Netscape Navigator 6 using the "User-Agent" string.

Parameters:
req - HttpServletRequest
Returns:
boolean: true if the client device is Netscape Navigator 6 or higher, false if otherwise

isPalm

public static boolean isPalm(javax.servlet.http.HttpServletRequest req)
Checks to see if client device is a Palm Pilot using the "User-Agent" string.

Parameters:
req - HttpServletRequest
Returns:
boolean: true if the client device is a Palm Pilot, false if otherwise

isTaskAssigned

public static final boolean isTaskAssigned(java.lang.String taskId,
                                           TaskContext context)
Checks if the user has access to the specified task.

Parameters:
taskId - String containing taskId to check for access (ex. "base.ModifyUser")
context - TaskContext of the plug-in
Returns:
boolean: true if the user can run the specified task, false if otherwise

join

public static final java.lang.String join(java.util.Collection collection)
Concatenates Strings in a Collection together separated with a "," delimiter.

Parameters:
collection - Collection object of Strings
Returns:
String made from concatenation of the Strings in the Collection and the delimiter (ex. "token1,token2,token3")

join

public static final java.lang.String join(java.util.Collection collection,
                                          java.lang.String delimiter)
Concatenates Strings in a Collection together separated with a delimiter.

Parameters:
collection - Collection object of Strings
delimiter - String containing the delimiter between tokens (ex. ".")
Returns:
String made from concatenation of the Strings in the Collection and the delimiter (ex. "token1.token2.token3")

newDocument

public static final org.w3c.dom.Document newDocument()
Instanciates an empty org.w3c.Document.

Returns:
Document that is empty

out

public static final void out(org.w3c.dom.Document doc)
Deprecated. As of iManager 2.5. Will be removed. Use D.log(org.w3c.dom.Document doc)

Outputs an XML document to error log.

Parameters:
doc - XML Document to output

pack

public static final java.lang.String pack(java.lang.String[] list,
                                          PluginContext context)
Packs a String array into one string. Useful for packing data for posting in HTML.

Parameters:
list - String array containing the values
context - PluginContext of the plug-in
Returns:
String containing the packed values

pack

public static final java.lang.String pack(java.lang.String value1,
                                          java.lang.String value2,
                                          PluginContext context)
Packs a pair of strings into one string. Useful for packaging data for posting in HTML.

Parameters:
value1 - String containing the first value
value2 - String containing the second value
context - PluginContext of the plug-in
Returns:
String containing the packed values

parseParameters

public static final java.util.Properties parseParameters(java.lang.String params)
Parses a semi-colon delimited string of key/value pairs (ex. "key1=val1;key2=val2").

Parameters:
params - String containing semi-colon delimited string of key/value pairs (ex. key1=val1;key2=val2)
Returns:
Properties object containing key and value pairs

parseParameters

public static final java.util.Properties parseParameters(java.lang.String params,
                                                         java.lang.String delimiter)
Parses a delimited string of key/value pairs. For example, "key1=val1;key2=val2". The delimiter can be specified.

Parameters:
params - A delimited string of key/value pairs; for example: "key1=val1;key2=val2"
delimiter - The delimiter between the key/value pairs; for example: ";"
Returns:
A Properties object containing key and value pairs

parseParameters2

public static final java.util.HashMap parseParameters2(java.lang.String params)
Parses a semi-colon delimited string of key/value pairs (ex. "key1=val1;key2=val2") and returns result in a HashMap.

Parameters:
params - String containing semi-colon delimited string of key/value pairs (ex. "key1=val1;key2=val2")
Returns:
HashMap object containing key and value pairs

refreshOV

public static final void refreshOV(PluginContext context)
Tasks that delete or created object should call this to ensure the object view is refreshed.

Parameters:
context - PluginContext of the plug-in

refreshResourceFileMap

public static void refreshResourceFileMap(java.lang.String map)
                                   throws java.io.FileNotFoundException
Refreshes the filemap. Must be called if new JSP files are created on the filesystem.

Parameters:
map - String containing the name of the file map (usually this is the module id)
Throws:
java.io.FileNotFoundException

replaceSubString

public static java.lang.String replaceSubString(java.lang.String source,
                                                java.lang.String fromSubString,
                                                java.lang.String toSubString)
Simple string replacement method.

Parameters:
source - Original string
fromSubString - String containing substring to replace in the original string
toSubString - String containing the replacement substring
Returns:
The new String

replaceWith

public static java.lang.String replaceWith(java.lang.String strOrig,
                                           java.lang.String strFind,
                                           java.lang.String strReplace)
Simple string replacement method.

Parameters:
strOrig - Original string
strFind - String to find in original string
strReplace - String to replace strFind in origial string
Returns:
The new String

reverseBytes

public static byte[] reverseBytes(byte[] bytes)
Reverses a byte array.

Parameters:
bytes - The byte array to reverse
Returns:
new byte array

setErrorMessage

public static void setErrorMessage(java.lang.Throwable t,
                                   TaskContext context)
Sets the error information in the results for the current request. The following variables are made available to the template rendering the results:
GeneralMsg.Mode is set to "error",
GeneralMsg.MsgTitle is set to the header parameter, and
GeneralMsg.MsgBody is set to the body parameter.
These strings can then be used by a template (GenMsg.htt) to format the display of the error message.

Parameters:
t - The exception with the error to display. If the exception is an SPI excetion, the error messages are retrieved from it and a result string named GeneralMsg.Error.Detail is added which contains the name of the HTML help file explaining the error. If the exception is a PluginException, the error messages from the root exception (in the case of nested exceptions) are retrieved. If the exception is a NamespaceException, an appropriate message is generated. For other exceptions, a general messages is used, and a stackTrace is added to a string named stackTrace.
context - TaskContext of the plug-in

setErrorTemplate

public static void setErrorTemplate(PluginContext context,
                                    java.lang.String template)
Sets the JSP file to be used for rendering of response if Task.execute returns false.

Parameters:
context - PluginContext of the plug-in
template - String containing the .jsp file to set as the "error" parameter on the HttpServletRequest
See Also:
getErrorTemplate(com.novell.emframe.dev.PluginContext)

setMergeTemplate

public static void setMergeTemplate(PluginContext context,
                                    java.lang.String template)
Sets the JSP file to be used for rendering of response.

Parameters:
context - PluginContext of the plug-in
template - String containing the .jsp file to set as the "merge" parameter on the HttpServletRequest
See Also:
getMergeTemplate(com.novell.emframe.dev.PluginContext)

setMessage

public static final void setMessage(java.lang.String messageMode,
                                    java.lang.String title,
                                    java.lang.String plainText,
                                    java.lang.String boldText,
                                    java.lang.String errorDetails,
                                    TaskContext context)
Sets error/success message with plain and bold text as well as error details. Automatically calls setModuleStylesheet() to use GenConf.jsp, GenMsg.jsp, or GenErr.jsp.

Parameters:
messageMode - String containing "success", "error", or "fatal"
title - String containing localized title of error
plainText - String containing localized body of error; should contain a {0} to be replaced with bold
boldText - String containing part of message to be bolded
errorDetails - String containing more details of error message
context - TaskContext of the plug-in

setMessage

public static final void setMessage(java.lang.String messageMode,
                                    java.lang.String title,
                                    java.lang.String plainText,
                                    java.lang.String boldText,
                                    TaskContext context)
Sets error/success message with plain and bold text. Automatically calls setModuleStylesheet() to use GenConf.jsp, GenMsg.jsp, or GenErr.jsp.

Parameters:
messageMode - String containing "success", "error", or "fatal"
title - String containing localized title of error
plainText - String containing localized body of error; should contain a {0} to be replaced with bold
boldText - String containing part of message to be bolded
context - TaskContext of the plug-in

setMessage

public static final void setMessage(java.lang.String messageMode,
                                    java.lang.String title,
                                    java.lang.String body,
                                    TaskContext context)
Sets error/success message. Automatically calls setModuleStylesheet() to use GenConf.jsp, GenMsg.jsp, or GenErr.jsp.

Parameters:
messageMode - String containing "success", "error", or "fatal"
title - String containing localized title of error
body - String containing localized body of error
context - TaskContext of the plug-in

setMooErrorMessage

public static void setMooErrorMessage(java.util.Properties resultStrings,
                                      java.lang.String header,
                                      java.lang.String body,
                                      java.util.ArrayList errors)
Sets the error messages for a Multiple Object Operation.

Parameters:
resultStrings - Properties object containing the list of strings available to the template during rendering.
header - String containing the title of the error
body - String containing the error message to display as the body of the message
errors - ArrayList of error messages. This should be a list of arrays. Each array in the list should have three elements.
The first element (index 0) should be the object name that the error occured on.
The second element should be the title of the error.
The third element should be the error message.

setPersistentData

public static void setPersistentData(java.lang.String keyId,
                                     java.lang.String data,
                                     TaskContext context)
Sets the key and data in the user's persistent store.

Parameters:
keyId - String containing the key
data - String containing the value data
context - TaskContext of the plug-in
See Also:
getPersistentData(java.lang.String, com.novell.emframe.dev.TaskContext)

setupTargetChooser

public static final void setupTargetChooser(java.lang.String[] objectTypeNames,
                                            TaskContext context)
Must be called during the server side processing on the request before the TargetChooser widget is used. This method sets up data that the widget will need.
Note: there can only be one target chooser widget on a page.

outputs:
TC.objectTypeNames - used by os.filter
TC.packedObjectTypeNames - used to display to user
TC.defaultPrompt - used as prompt if not specified
if taskDisplayName=null we will use task displayName

TC.baseObjectTypes.i
TC.baseObjectTypes.count
TC.defaultPrompt
TC.baseObjectTypes.i
TC.baseObjectTypes.count
TC.packedObjectTypeNames
TC.objectTypeNames
TC.packRealObjectClassNames
Task.defaultDisplayName
Task.DefalutIcon.alt
Task.DefaultIcon.name
Task.DefalutIcon.alt
History.count
History.i.name
History.i.type

Parameters:
objectTypeNames - String array containing case sensitive names of the object classes that are valid for the TargetChooser (* for all)
context - TaskContext of the plug-in

setupTargetChooser

public static final void setupTargetChooser(TaskContext context,
                                            java.util.Properties resultStrings,
                                            java.lang.String[] objectTypeNames)
Deprecated. use setupTargetChooser( context, objectTypeNames )

Must be called during the server side processing on the request before the TargetChooser widget is used. This method sets up data that the widget will need.
Note: there can only be one target chooser widget on a page.

outputs:
TC.objectTypeNames - used by os.filter
TC.packedObjectTypeNames - used to display to user
TC.defaultPrompt - used as prompt if not specified
if taskDisplayName=null we will use task displayName

TC.baseObjectTypes.i
TC.baseObjectTypes.count
TC.defaultPrompt
TC.baseObjectTypes.i
TC.baseObjectTypes.count
TC.packedObjectTypeNames
TC.objectTypeNames
TC.packRealObjectClassNames
Task.defaultDisplayName
Task.DefalutIcon.alt
Task.DefaultIcon.name
Task.DefalutIcon.alt
History.count
History.i.name
History.i.type

Parameters:
objectTypeNames - String array containing case sensitive names of the object classes that are valid for the TargetChooser (* for all)
resultStrings - Properties object no longer used
context - TaskContext of the plug-in
See Also:
setupTargetChooser(java.lang.String[], com.novell.emframe.dev.TaskContext)

sortKeyValues

public static final void sortKeyValues(java.util.ArrayList keys,
                                       java.util.ArrayList values,
                                       TaskContext context)
Takes two String ArrayLists, keys and values, and sorts the keys array moving the values in the value array to corresponding index positions.

Parameters:
keys - An ArrayList of String entries to be sorted
values - An ArrayList of corresponding string values
context - TaskContext of the plug-in

sortStringArray

public static final void sortStringArray(java.lang.String[] myArray)
Sorts a String array while ignoring case.

Parameters:
myArray - String array to be sorted

split

public static final java.lang.String[] split(java.lang.String s,
                                             java.lang.String delimiter)
Tokenize a string into a String array of tokens.

Parameters:
s - String containing tokens seperated by delimiter (ex. "token1.token2.token3")
delimiter - String containing the delimiter between tokens (ex. ".")
Returns:
String array containing the tokens in the string

toDisplay

public static java.lang.String toDisplay(java.lang.String strText)
Method to escape string for use in HTML. (ex. converts greater than '>' and less than '<' chars).

Parameters:
strText - String to escape
Returns:
String safe to display in HTML

toHexString

public static final java.lang.String toHexString(byte[] bytes)
Converts a byte array to a hex string.

Parameters:
bytes - byte array of values
Returns:
String representing the hex value of the array

tokenize

public static final java.util.Vector tokenize(java.lang.String params,
                                              java.lang.String delimiter)
Tokenize a string into a Vector of tokens.

Parameters:
params - String containing tokens seperated by delimiter (ex. "token1.token2.token3")
delimiter - String containing the delimiter between tokens (ex. ".")
Returns:
Vector containing the tokens in the string

toOSFilterString

public static java.lang.String toOSFilterString(java.lang.String[] types)
Creates a String that can be used as an ObjectSelector filter string. OS expects comma seperated; commas must be escaped; This routines does that for you.

Parameters:
types - String array of object class names
Returns:
String containing all item in list

toScript

public static java.lang.String toScript(java.lang.String strText)
Escapes the characters single quote ('), double quote ("), backslash (\) by inserting a backslash before each occurance.

Parameters:
strText - String containing text to encode
Returns:
String safe for merging into Javascript

toTag

public static java.lang.String toTag(java.lang.String str)
Escapes chars for use in HTML tags. (ex. escapes greater than '>', less than '<', quotes '"', etc...).

Parameters:
str - String to escape
Returns:
String safe to use in HTML tags

trimQuotes

public static final java.lang.String trimQuotes(java.lang.String str)
Removes the leading and trailing quotes from a String object.

If the String has a leading and a trailing quote character, the quotes will be removed.

Parameters:
str - String that will have its quotes removed
Returns:
String with leading and trailing quotes removed

unpack

public static final java.lang.String[] unpack(java.lang.String s,
                                              PluginContext context)
Unpacks data packed with the pack routine.

Parameters:
s - String containing a valid packed string. The empty string is not valid.
context - PluginContext of the plug-in
Returns:
String array of values

urlDecode

public static final java.lang.String urlDecode(java.lang.String s,
                                               PluginContext context)
Decodes String that has been urlEncoded.

Parameters:
s - String to decode
context - PluginContext used to get the character encoding. If null then the default of utf-8 will be used.
Returns:
The decoded String
See Also:
urlEncode(java.lang.String, java.lang.String)

urlDecode

public static final java.lang.String urlDecode(java.lang.String s,
                                               java.lang.String encoding)
Decodes string that has been urlEncoded.

Parameters:
s - String to decode
encoding - String containing the encoding to use. If this is null, "8859_1" will be used.
Returns:
The decoded String
See Also:
urlEncode(java.lang.String, java.lang.String)

urlEncode

public static java.lang.String urlEncode(java.lang.String strText)
URL encodes using utf-8 encoding.

Parameters:
strText - String to encode
Returns:
String safe for use on URLs

urlEncode

public static final java.lang.String urlEncode(java.lang.String s,
                                               PluginContext context)
Encodes URL for strings.

Parameters:
s - String to encode
context - PluginContext used to get the character encoding. If null then the default of utf-8 will be used.
Returns:
The encoded String
See Also:
urlDecode(java.lang.String, com.novell.emframe.dev.PluginContext)

urlEncode

public static java.lang.String urlEncode(java.lang.String strText,
                                         java.lang.String charset)
Encodes all characters except 0-9, A-Z, and a-z.

Parameters:
strText - String to encode
charset - String containing character set for encoding
Returns:
String safe for use in GET urls

urlEncodePath

public static java.lang.String urlEncodePath(java.lang.String strText)
Encodes all characters except 0-9, A-Z, and a-z and '/'. URL encodes using utf-8 encoding.

Parameters:
strText - String to encode
Returns:
String safe for use with GET urls

urlEncodePath

public static java.lang.String urlEncodePath(java.lang.String strText,
                                             java.lang.String charset)
Encodes all characters except 0-9, A-Z, and a-z and '/'.

Parameters:
strText - String to encode
charset - String containing charset to use for encoding
Returns:
String safe for use with GET urls

xmlDecode

public static java.lang.String xmlDecode(java.lang.String str)
Decodes string that has been escape for XML.

Parameters:
str - String to decode
Returns:
Decoded String

xmlEncode

public static java.lang.String xmlEncode(java.lang.String strText)
Escapes chars for use in XML.

Parameters:
strText - String to escape
Returns:
String safe for use in XML


API Documentation Copyright © 1998-2004 Novell, Inc. All rights reserved.
NDS is a registered trademark of Novell, Inc. in the United States and other countries.
Generated September 2 2004 0111.