gov.nih.nci.cagrid.common
Class Utils

java.lang.Object
  extended by gov.nih.nci.cagrid.common.Utils

public class Utils
extends java.lang.Object


Constructor Summary
Utils()
           
 
Method Summary
static java.lang.Object appendToArray(java.lang.Object array, java.lang.Object appendix)
          Appends to an array
static java.lang.String clean(java.lang.String s)
           
static java.lang.Object cloneBean(java.lang.Object bean, javax.xml.namespace.QName qname)
           
static java.lang.Object concatenateArrays(java.lang.Class resultClass, java.lang.Object arr1, java.lang.Object arr2)
          Merges the two arrays (not necessarily creating a new array).
static void copyDirectory(java.io.File srcDir, java.io.File dstDir)
           
static void copyFile(java.io.File in, java.io.File out)
           
static boolean deleteDir(java.io.File dir)
           
static java.lang.Object deserializeDocument(java.lang.String fileName, java.lang.Class objectType)
           
static java.lang.Object deserializeObject(java.io.Reader xmlReader, java.lang.Class clazz)
           
static java.lang.Object deserializeObject(java.io.Reader xmlReader, java.lang.Class clazz, java.io.InputStream wsdd)
          Deserializes XML into an object
static boolean equals(java.lang.Object o1, java.lang.Object o2)
           
static java.lang.StringBuffer fileToStringBuffer(java.io.File file)
           
static java.io.File getCaGridUserHome()
           
static java.lang.String getExceptionMessage(java.lang.Throwable e)
           
static java.lang.Class getRegisteredClass(javax.xml.namespace.QName qname)
          Gets the Class that Axis has registerd for the given QName
static javax.xml.namespace.QName getRegisteredQName(java.lang.Class clazz)
          Gets the QName that Axis has registered for the given java class
static java.lang.String getRelativePath(java.io.File source, java.io.File destination)
          Gets a relative path from the source file to the destination
static java.io.File getTrustedCerificatesDirectory()
           
static java.lang.StringBuffer inputStreamToStringBuffer(java.io.InputStream stream)
           
static java.util.List<java.io.File> recursiveListFiles(java.io.File baseDir, java.io.FileFilter filter)
           
static java.lang.Object removeFromArray(java.lang.Object array, java.lang.Object removal)
          Removed an object from an array.
static void serializeDocument(java.lang.String fileName, java.lang.Object object, javax.xml.namespace.QName qname)
           
static void serializeObject(java.lang.Object obj, javax.xml.namespace.QName qname, java.io.Writer writer)
           
static void serializeObject(java.lang.Object obj, javax.xml.namespace.QName qname, java.io.Writer writer, java.io.InputStream wsdd)
          Serialize an Object to XML
static java.lang.String simplifyErrorMessage(java.lang.String m)
           
static void stringBufferToFile(java.lang.StringBuffer string, java.lang.String fileName)
           
static void validateCertificateChain(java.security.cert.X509Certificate[] chain)
           
static void validateGlobusCredential(org.globus.gsi.GlobusCredential cred)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

getCaGridUserHome

public static java.io.File getCaGridUserHome()

getTrustedCerificatesDirectory

public static java.io.File getTrustedCerificatesDirectory()

validateGlobusCredential

public static void validateGlobusCredential(org.globus.gsi.GlobusCredential cred)
                                     throws org.globus.gsi.proxy.ProxyPathValidatorException
Throws:
org.globus.gsi.proxy.ProxyPathValidatorException

validateCertificateChain

public static void validateCertificateChain(java.security.cert.X509Certificate[] chain)
                                     throws org.globus.gsi.proxy.ProxyPathValidatorException
Throws:
org.globus.gsi.proxy.ProxyPathValidatorException

getExceptionMessage

public static java.lang.String getExceptionMessage(java.lang.Throwable e)

simplifyErrorMessage

public static java.lang.String simplifyErrorMessage(java.lang.String m)

deserializeDocument

public static java.lang.Object deserializeDocument(java.lang.String fileName,
                                                   java.lang.Class objectType)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

copyFile

public static void copyFile(java.io.File in,
                            java.io.File out)
                     throws java.io.IOException
Throws:
java.io.IOException

copyDirectory

public static void copyDirectory(java.io.File srcDir,
                                 java.io.File dstDir)
                          throws java.io.IOException
Throws:
java.io.IOException

deleteDir

public static boolean deleteDir(java.io.File dir)

concatenateArrays

public static java.lang.Object concatenateArrays(java.lang.Class resultClass,
                                                 java.lang.Object arr1,
                                                 java.lang.Object arr2)
                                          throws java.lang.ArrayStoreException
Merges the two arrays (not necessarily creating a new array). If both are null, null is returned. If one is null, the other is returned.

Throws:
java.lang.ArrayStoreException - uses System.arrarycopy and has same contract

appendToArray

public static java.lang.Object appendToArray(java.lang.Object array,
                                             java.lang.Object appendix)
Appends to an array

Parameters:
array - The array to append to
appendix - The object to append to the array
Returns:
An array with the new item appended

removeFromArray

public static java.lang.Object removeFromArray(java.lang.Object array,
                                               java.lang.Object removal)
Removed an object from an array.

Parameters:
array -
removal -
Returns:
An array with the item removed

fileToStringBuffer

public static java.lang.StringBuffer fileToStringBuffer(java.io.File file)
                                                 throws java.io.IOException
Throws:
java.io.IOException

inputStreamToStringBuffer

public static java.lang.StringBuffer inputStreamToStringBuffer(java.io.InputStream stream)
                                                        throws java.io.IOException
Throws:
java.io.IOException

serializeObject

public static void serializeObject(java.lang.Object obj,
                                   javax.xml.namespace.QName qname,
                                   java.io.Writer writer,
                                   java.io.InputStream wsdd)
                            throws java.lang.Exception
Serialize an Object to XML

Parameters:
obj - The object to be serialized
qname - The QName of the object
writer - A writer to place XML into (eg: FileWriter, StringWriter). If a file writer is used, be sure to close it!
wsdd - A stream containing the WSDD configuration
Throws:
java.lang.Exception

serializeObject

public static void serializeObject(java.lang.Object obj,
                                   javax.xml.namespace.QName qname,
                                   java.io.Writer writer)
                            throws java.lang.Exception
Throws:
java.lang.Exception

deserializeObject

public static java.lang.Object deserializeObject(java.io.Reader xmlReader,
                                                 java.lang.Class clazz,
                                                 java.io.InputStream wsdd)
                                          throws org.xml.sax.SAXException,
                                                 org.globus.wsrf.encoding.DeserializationException
Deserializes XML into an object

Parameters:
xmlReader - The reader for the XML (eg: FileReader, StringReader, etc)
clazz - The class to serialize to
wsdd - A stream containing the WSDD configuration
Returns:
The object deserialized from the XML
Throws:
org.xml.sax.SAXException
org.globus.wsrf.encoding.DeserializationException

deserializeObject

public static java.lang.Object deserializeObject(java.io.Reader xmlReader,
                                                 java.lang.Class clazz)
                                          throws java.lang.Exception
Throws:
java.lang.Exception

serializeDocument

public static void serializeDocument(java.lang.String fileName,
                                     java.lang.Object object,
                                     javax.xml.namespace.QName qname)
                              throws java.lang.Exception
Throws:
java.lang.Exception

clean

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

stringBufferToFile

public static void stringBufferToFile(java.lang.StringBuffer string,
                                      java.lang.String fileName)
                               throws java.io.IOException
Throws:
java.io.IOException

equals

public static boolean equals(java.lang.Object o1,
                             java.lang.Object o2)

getRegisteredQName

public static javax.xml.namespace.QName getRegisteredQName(java.lang.Class clazz)
Gets the QName that Axis has registered for the given java class

Parameters:
clazz -
Returns:
The QName corresponding to the class registered in the Axis type mappings

getRegisteredClass

public static java.lang.Class getRegisteredClass(javax.xml.namespace.QName qname)
Gets the Class that Axis has registerd for the given QName

Parameters:
qname -
Returns:
The class corresponding to the QName as registered in the Axis type mappings

recursiveListFiles

public static java.util.List<java.io.File> recursiveListFiles(java.io.File baseDir,
                                                              java.io.FileFilter filter)

getRelativePath

public static java.lang.String getRelativePath(java.io.File source,
                                               java.io.File destination)
                                        throws java.io.IOException
Gets a relative path from the source file to the destination

Parameters:
source - The source file or location
destination - The file to target with the relative path
Returns:
The relative path from the source file's directory to the destination file
Throws:
java.io.IOException

cloneBean

public static java.lang.Object cloneBean(java.lang.Object bean,
                                         javax.xml.namespace.QName qname)
                                  throws java.lang.Exception
Throws:
java.lang.Exception