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 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 groovy.lang.Binding fillBinding(java.util.HashMap attrs)
           
static groovy.lang.Binding fillBinding(it.eng.spago.security.IEngUserProfile profile)
           
static java.util.HashMap getAllProfileAttributes()
          Get all the shared profile attributes of the users.
static byte[] getByteArrayFromInputStream(java.io.InputStream is)
          Given an InputStream as input, gets the correspondent bytes array.
static java.lang.String getLocalIPAddressAsString()
          Returns a string containing the localhost IP address.
static java.util.HashMap getPredefinedProfileAttributes(java.lang.String userUniqueIdentifier)
          Get all the predefined profile attributes of the user with the given unique identifier passed as 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 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 getSpagoBiEventsManagerServlet()
          Gets the spagoBI's EventManager servlet information as a string.
static void main(java.lang.String[] args)
          The Main method
static java.lang.String substituteProfileAttributesInQuery(java.lang.String statement, java.util.HashMap profileattrs, int profileAttributeStartIndex)
          Substitutes the profile attributes with sintax "${attribute_name}" with the correspondent value in the query statement passed at input.
static java.lang.String testScript(java.lang.String script, groovy.lang.Binding bind)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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

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.

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

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

getAllProfileAttributes

public static java.util.HashMap getAllProfileAttributes()
Get all the shared profile attributes of the users. The attributes are contained into a configuration file which contains the name of the attribute and the test value of the attribute. The test value is used during the test of a script that use the attribute.

Returns:
HashMap of the attributes. HashMap keys are profile attribute. HashMap values are test values.

getPredefinedProfileAttributes

public static java.util.HashMap getPredefinedProfileAttributes(java.lang.String userUniqueIdentifier)
Get all the predefined profile attributes of the user with the given unique identifier passed as String. The attributes are contained into a configuration file which contains the name of the attribute and the test value of the attribute. The test value is used during the test of a script that use the attribute.

Returns:
HashMap of the attributes. HashMap keys are profile attribute. HashMap values are test values.

fillBinding

public static groovy.lang.Binding fillBinding(java.util.HashMap attrs)

fillBinding

public static groovy.lang.Binding fillBinding(it.eng.spago.security.IEngUserProfile profile)
                                       throws it.eng.spago.error.EMFInternalError
Throws:
it.eng.spago.error.EMFInternalError

substituteProfileAttributesInQuery

public static java.lang.String substituteProfileAttributesInQuery(java.lang.String statement,
                                                                  java.util.HashMap profileattrs,
                                                                  int profileAttributeStartIndex)
                                                           throws java.lang.Exception
Substitutes the profile attributes with sintax "${attribute_name}" with the correspondent value in the query statement passed at input.

Parameters:
statement - The query statement string to be modified
profileattrs - The profile attributes HashMap
profileAttributeStartIndex - The start index for query parsing (useful for recursive calling)
Returns:
The statement with profile attributes replaced by their values.
Throws:
java.lang.Exception

testScript

public static java.lang.String testScript(java.lang.String script,
                                          groovy.lang.Binding bind)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

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