it.eng.spagobi.utilities
Class GeneralUtilities

java.lang.Object
  extended by it.eng.spagobi.utilities.GeneralUtilities

public class GeneralUtilities
extends java.lang.Object

Contains some SpagoBI's general utilities.


Constructor Summary
GeneralUtilities()
           
 
Method Summary
static java.lang.String cleanString(java.lang.String original)
          Cleans a string from spaces and tabulation characters.
static java.lang.String decode(java.lang.String input)
          Questo metodo implementa la stessa logica della funzione javascript escape.
static boolean deleteContentDir(java.io.File dir)
          Delete contents of a directory
static boolean deleteDir(java.io.File dir)
          Delete a folder and its contents
static java.lang.String encode(java.lang.String input)
          Questo metodo implementa la stessa logica della funzione javascript escape.
static void flushFromInputStreamToOutputStream(java.io.InputStream is, java.io.OutputStream os, boolean closeStreams)
          Given an InputStream as input flushs the content into an OutputStream and then close the input and output stream.
static java.lang.String fromListToString(java.util.List values, java.lang.String separator)
           
static java.util.HashMap getAllProfileAttributes(it.eng.spago.security.IEngUserProfile profile)
           
static byte[] getByteArrayFromInputStream(java.io.InputStream is)
          Given an InputStream as input, gets the correspondent bytes array.
static java.util.Locale getDefaultLocale()
           
static java.lang.String getLocalIPAddressAsString()
          Returns a string containing the localhost IP address.
static java.lang.String getLovMapResult(java.util.Map lovs)
           
static java.lang.String getLovResult(java.lang.String lovLabel)
           
static java.lang.String getLovResult(java.lang.String lovLabel, it.eng.spago.security.IEngUserProfile profile)
           
static java.lang.String getMapCatalogueManagerServlet()
          Gets the spagoBI's MapCatalogueManager servlet information as a string.
static java.lang.String getRelativeFileNames(java.lang.String completeFileName)
          From a String identifying the complete name for a file, gets the relative file names, which are substrings of the starting String, according to the java separator "/".
static java.lang.String getSpagoBiAuditManagerServlet()
          Gets the spagoBI's AuditManager servlet information as a string.
static java.lang.String getSpagoBiContentRepositoryServlet()
          Gets the spagoBI's content repository servlet information as a string.
static java.lang.String getSpagoBiContextAddress()
          Returns the context address for SpagoBI as an URL and puts it into a string.
static java.lang.String getSpagoBiDashboardServlet()
          Gets the spagoBI's dashboards servlet information as a string.
static java.lang.String getSpagoBiEventsManagerServlet()
          Gets the spagoBI's EventManager servlet information as a string.
static boolean isErrorHandlerContainingOnlyValidationError(it.eng.spago.error.EMFErrorHandler errorHandler)
          Checks if the Spago errorHandler contains only validation errors
static boolean isModuleInstalled(java.lang.String moduleName)
          checks if a module is installed (based on the configuration file spagobi_components.xml)
static void main(java.lang.String[] args)
          The Main method
static java.lang.String quote(java.lang.String s)
           
static java.lang.String replace(java.lang.String toParse, java.lang.String replacing, java.lang.String replaced)
          Questo metodo permette di sostituire una parte di una stringa con un'altra.
static java.lang.String replaceInternationalizedMessages(java.lang.String message)
          Substitutes the substrings with sintax "${code,bundle}" or "${code}" (in the second case bundle is assumed to be the default value "messages") with the correspondent internationalized messages in the input String.
static void subsituteBIObjectParametersLovProfileAttributes(BIObject obj, it.eng.spago.base.SessionContainer session)
           
static java.lang.String substituteProfileAttributesInString(java.lang.String statement, it.eng.spago.security.IEngUserProfile profile)
          Substitutes the profile attributes with sintax "${attribute_name}" with the correspondent value in the string passed at input.
static java.lang.String substituteQuotesIntoString(java.lang.String value)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralUtilities

public GeneralUtilities()
Method Detail

main

public static void main(java.lang.String[] args)
The Main method

Parameters:
args - String for command line arguments

getDefaultLocale

public static java.util.Locale getDefaultLocale()

cleanString

public static java.lang.String cleanString(java.lang.String original)
Cleans a string from spaces and tabulation characters.

Parameters:
original - The input string
Returns:
The cleaned string

isErrorHandlerContainingOnlyValidationError

public static boolean isErrorHandlerContainingOnlyValidationError(it.eng.spago.error.EMFErrorHandler errorHandler)
Checks if the Spago errorHandler contains only validation errors

Parameters:
errorHandler - The error handler to check
Returns:
true if the errorHandler contains only validation error, false if erroHandler is empty or contains not only validation error.

getByteArrayFromInputStream

public static byte[] getByteArrayFromInputStream(java.io.InputStream is)
Given an InputStream as input, gets the correspondent bytes array.

Parameters:
is - The input straeam
Returns:
An array of bytes obtained from the input stream.

flushFromInputStreamToOutputStream

public static void flushFromInputStreamToOutputStream(java.io.InputStream is,
                                                      java.io.OutputStream os,
                                                      boolean closeStreams)
Given an InputStream as input flushs the content into an OutputStream and then close the input and output stream.

Parameters:
is - The input stream
os - The output stream
closeStreams, - if true close both stream

getRelativeFileNames

public static java.lang.String getRelativeFileNames(java.lang.String completeFileName)
From a String identifying the complete name for a file, gets the relative file names, which are substrings of the starting String, according to the java separator "/".

Parameters:
completeFileName - The string representing the file name
Returns:
relative names substring

getLocalIPAddressAsString

public static java.lang.String getLocalIPAddressAsString()
Returns a string containing the localhost IP address.

Returns:
The IP address String

getSpagoBiContextAddress

public static java.lang.String getSpagoBiContextAddress()
Returns the context address for SpagoBI as an URL and puts it into a string. The information contained are the Srever name and port. Before saving, both them are written into the output console.

Returns:
A String with SpagoBI's context adderss

getSpagoBiContentRepositoryServlet

public static java.lang.String getSpagoBiContentRepositoryServlet()
Gets the spagoBI's content repository servlet information as a string.

Returns:
A string containing spagoBI's content repository servlet information

getSpagoBiDashboardServlet

public static java.lang.String getSpagoBiDashboardServlet()
Gets the spagoBI's dashboards servlet information as a string.

Returns:
A string containing spagoBI's dashboards servlet information

getSpagoBiEventsManagerServlet

public static java.lang.String getSpagoBiEventsManagerServlet()
Gets the spagoBI's EventManager servlet information as a string.

Returns:
A string containing spagoBI's EventManager servlet information

getMapCatalogueManagerServlet

public static java.lang.String getMapCatalogueManagerServlet()
Gets the spagoBI's MapCatalogueManager servlet information as a string.

Returns:
A string containing spagoBI's MapCatalogueManager servlet information

getSpagoBiAuditManagerServlet

public static java.lang.String getSpagoBiAuditManagerServlet()
Gets the spagoBI's AuditManager servlet information as a string.

Returns:
A string containing spagoBI's AuditManager servlet information

substituteProfileAttributesInString

public static java.lang.String substituteProfileAttributesInString(java.lang.String statement,
                                                                   it.eng.spago.security.IEngUserProfile profile)
                                                            throws java.lang.Exception
Substitutes the profile attributes with sintax "${attribute_name}" with the correspondent value in the string passed at input.

Parameters:
statement - The string to be modified (tipically a query)
profile - The IEngUserProfile object
Returns:
The statement with profile attributes replaced by their values.
Throws:
java.lang.Exception

quote

public static java.lang.String quote(java.lang.String s)

getAllProfileAttributes

public static java.util.HashMap getAllProfileAttributes(it.eng.spago.security.IEngUserProfile profile)
                                                 throws it.eng.spago.error.EMFInternalError
Throws:
it.eng.spago.error.EMFInternalError

deleteDir

public static boolean deleteDir(java.io.File dir)
Delete a folder and its contents

Parameters:
dir - The java file object of the directory
Returns:
the result of the operation

deleteContentDir

public static boolean deleteContentDir(java.io.File dir)
Delete contents of a directory

Parameters:
dir - The java file object of the directory
Returns:
the result of the operation

replaceInternationalizedMessages

public static java.lang.String replaceInternationalizedMessages(java.lang.String message)
Substitutes the substrings with sintax "${code,bundle}" or "${code}" (in the second case bundle is assumed to be the default value "messages") with the correspondent internationalized messages in the input String. This method calls PortletUtilities.getMessage(key, bundle).

Parameters:
message - The string to be modified
Returns:
The message with the internationalized substrings replaced.

replace

public static java.lang.String replace(java.lang.String toParse,
                                       java.lang.String replacing,
                                       java.lang.String replaced)
Questo metodo permette di sostituire una parte di una stringa con un'altra.

Parameters:
toParse - stringa da manipolare.
replacing - parte di stringa da sostituire.
replaced - stringa nuova.

encode

public static java.lang.String encode(java.lang.String input)
Questo metodo implementa la stessa logica della funzione javascript escape.

Parameters:
input - stringa da manipolare.

decode

public static java.lang.String decode(java.lang.String input)
Questo metodo implementa la stessa logica della funzione javascript escape.

Parameters:
input - stringa da manipolare.

subsituteBIObjectParametersLovProfileAttributes

public static void subsituteBIObjectParametersLovProfileAttributes(BIObject obj,
                                                                   it.eng.spago.base.SessionContainer session)
                                                            throws java.lang.Exception,
                                                                   it.eng.spago.error.EMFInternalError
Throws:
java.lang.Exception
it.eng.spago.error.EMFInternalError

isModuleInstalled

public static boolean isModuleInstalled(java.lang.String moduleName)
checks if a module is installed (based on the configuration file spagobi_components.xml)

Parameters:
moduleName - The name of the module
Returns:
true if the module is installed, false otherwise

substituteQuotesIntoString

public static java.lang.String substituteQuotesIntoString(java.lang.String value)

getLovMapResult

public static java.lang.String getLovMapResult(java.util.Map lovs)

getLovResult

public static java.lang.String getLovResult(java.lang.String lovLabel)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

getLovResult

public static java.lang.String getLovResult(java.lang.String lovLabel,
                                            it.eng.spago.security.IEngUserProfile profile)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

fromListToString

public static java.lang.String fromListToString(java.util.List values,
                                                java.lang.String separator)