Example usage for org.springframework.dao DataAccessException getCause

List of usage examples for org.springframework.dao DataAccessException getCause

Introduction

In this page you can find the example usage for org.springframework.dao DataAccessException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

@SuppressWarnings("unchecked")
public Set<Qualifier> listQualifiersByName(String name, int searchCriteria)
        throws InvalidInputException, ObjectNotFoundException, AuthorizationException {
    if (name == null)
        throw new InvalidInputException();
    if (searchCriteria != AuthorizationManager.BEGINWITH && searchCriteria != AuthorizationManager.CONTAINS
            && searchCriteria != AuthorizationManager.EXACT)
        throw new InvalidInputException();
    List results = null;//  ww  w  . ja v  a2 s. co m
    String searchC = Integer.toString(searchCriteria);
    HibernateTemplate t = getHibernateTemplate();
    try {
        results = t.findByNamedQuery("QING_TEST_GETQUALIFIERSBYNAME_SP", new String[] { name, searchC });
    } catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    if (results == null)
        throw new ObjectNotFoundException("no qualifier found in database");

    Set<Qualifier> resultSet = new HashSet<Qualifier>(results);

    return resultSet;

}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

@SuppressWarnings("unchecked")
public Set<Qualifier> listQualifiersByCode(String code, int searchCriteria)
        throws InvalidInputException, ObjectNotFoundException, AuthorizationException {
    if (code == null)
        throw new InvalidInputException();

    if (searchCriteria != AuthorizationManager.BEGINWITH && searchCriteria != AuthorizationManager.CONTAINS
            && searchCriteria != AuthorizationManager.EXACT)
        throw new InvalidInputException();
    List results = null;//www . j  a v a  2s  .c  om
    String searchC = Integer.toString(searchCriteria);
    HibernateTemplate t = getHibernateTemplate();
    try {
        results = t.findByNamedQuery("QING_TEST_GETQUALIFIERSBYCODE_SP", new String[] { code, searchC });
    } catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    if (results == null)
        throw new ObjectNotFoundException("no qualifier found in database");

    Set<Qualifier> resultSet = new HashSet<Qualifier>(results);

    return resultSet;
}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

@SuppressWarnings("unchecked")
public Set<Function> listFunctionsByName(String name, int searchCriteria)
        throws InvalidInputException, ObjectNotFoundException, AuthorizationException {
    if (name == null)
        throw new InvalidInputException();

    if (searchCriteria != AuthorizationManager.BEGINWITH && searchCriteria != AuthorizationManager.CONTAINS
            && searchCriteria != AuthorizationManager.EXACT)
        throw new InvalidInputException();
    List results = null;//  w ww. j  av a 2s  . c  o m
    String searchC = Integer.toString(searchCriteria);
    HibernateTemplate t = getHibernateTemplate();
    try {
        results = t.findByNamedQuery("QING_TEST_GETFUNCTIONSBYNAME_SP", new String[] { name, searchC });
    } catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    if (results == null)
        throw new ObjectNotFoundException("no function found in database");

    Set<Function> resultSet = new HashSet<Function>(results);

    return resultSet;
}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

@SuppressWarnings("unchecked")
public Set<Function> listFunctionsByDescription(String desc, int searchCriteria)
        throws InvalidInputException, ObjectNotFoundException, AuthorizationException {
    if (desc == null)
        throw new InvalidInputException();

    if (searchCriteria != AuthorizationManager.BEGINWITH && searchCriteria != AuthorizationManager.CONTAINS
            && searchCriteria != AuthorizationManager.EXACT)
        throw new InvalidInputException();

    List results = null;//w  w w  . j a v  a  2  s.  com
    String searchC = Integer.toString(searchCriteria);

    HibernateTemplate t = getHibernateTemplate();
    try {
        results = t.findByNamedQuery("QING_TEST_GETFUNCTIONSBYDESC_SP", new String[] { desc, searchC });
    } catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    if (results == null)
        throw new ObjectNotFoundException("no function found in database");

    Set<Function> resultSet = new HashSet<Function>(results);

    return resultSet;
}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

/**
 * Select Categories for which userName is authorized. 
 *
 * @param userName user's kerberos Id/*from  w ww  .java2  s . co m*/
 * @throws  InvalidInputException if qualifier type code is NULL or if the code is more than 4 characters long
 * @throws  ObjectNotFoundException If no Qualifier is found 
 * @throws  AuthorizationException  in case of hibernate error   
 */
public Collection<PickableCategory> listFunctionCategories(String userName)
        throws InvalidInputException, PermissionException, AuthorizationException {
    if (userName == null)
        throw new InvalidInputException();

    String pname = userName.trim().toUpperCase();

    if (pname.length() <= 0)
        throw new InvalidInputException();

    HibernateTemplate t = getHibernateTemplate();

    Collection categories = null;
    try {
        categories = t.findByNamedQuery("FUNCTION_CATEGORY_LIST", pname);
        //categories = t.findByNamedQuery("FUNCTION_CATEGORY_LIST");
        t.initialize(categories);
    }

    catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    if (categories == null)
        throw new AuthorizationException("error retrieving categories for user " + userName);

    return categories;
}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

/**
 * Select Functions for which userName is authorized. 
 *
 * @param userName user's kerberos Id//from   ww  w.j a  v a2 s.  c om
 * @throws  InvalidInputException if qualifier type code is NULL or if the code is more than 4 characters long
 * @throws  ObjectNotFoundException If no Qualifier is found 
 * @throws  AuthorizationException  in case of hibernate error   
 */
public Collection<PickableFunction> listPickableFunctionsByCategory(String userName, String category)
        throws InvalidInputException, PermissionException, AuthorizationException {
    if (null == userName || null == category)
        throw new InvalidInputException();

    String pname = userName.trim().toUpperCase();
    String cat = category.trim().toUpperCase();

    if (pname.length() <= 0 || cat.length() <= 0)
        throw new InvalidInputException();

    HibernateTemplate t = getHibernateTemplate();
    Collection functions = null;
    try {
        functions = t.findByNamedQuery("FUNCTION_LIST_FOR_CATEGORY", new String[] { pname, cat });
        //System.out.println(t.toString());
        t.initialize(functions);
    }

    catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    if (functions == null)
        throw new AuthorizationException("error retrieving functions for user " + userName);

    return functions;
}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

/**
 * Select QualifierType for given Function
 *
 * @param userName user's kerberos Id/*www  .j  a  va2  s. c om*/
 * @param category function category
 * @param function_name function name
 * @throws  InvalidInputException if qualifier type code is NULL or if the code is more than 4 characters long
 * @throws  ObjectNotFoundException If no Qualifier is found 
 * @throws  AuthorizationException  in case of hibernate error   
 */
public String getQualifierTypeforFunction(String userName, String category, String function_name)
        throws InvalidInputException, PermissionException, AuthorizationException {
    if (null == userName || null == category || null == function_name)
        throw new InvalidInputException();

    String pname = userName.trim().toUpperCase();
    String cat = category.trim().toUpperCase();
    String fname = function_name.trim().toUpperCase();

    if (pname.length() <= 0 || cat.length() <= 0)
        throw new InvalidInputException();

    HibernateTemplate t = getHibernateTemplate();
    Collection<Function> functions = null;
    try {
        functions = t.findByNamedQuery("GET_FUNCTION_BY_CATEGORY_FUNCTION_NAME", new String[] { cat, fname });
        //System.out.println(t.toString());
        t.initialize(functions);
    }

    catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    if (functions == null)
        throw new AuthorizationException("error retrieving functions for user " + userName);

    return functions.iterator().next().getFqt().getType();
}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

/**
* Select QualifierType for given Function
*
* @param userName user's kerberos Id/* ww  w  . j av  a2  s . c o m*/
* @param category function category
* @param function_name function name
* @throws  InvalidInputException if function desc code is NULL 
* @throws  ObjectNotFoundException If no Function is found 
* @throws  AuthorizationException  in case of hibernate error   
*/
public String getFunctionDesc(String userName, String category, String function_name)
        throws InvalidInputException, PermissionException, AuthorizationException {
    if (null == userName || null == category || null == function_name)
        throw new InvalidInputException();

    String pname = userName.trim().toUpperCase();
    String cat = category.trim().toUpperCase();
    String fname = function_name.trim().toUpperCase();

    if (pname.length() <= 0 || cat.length() <= 0)
        throw new InvalidInputException();

    HibernateTemplate t = getHibernateTemplate();
    Collection<PickableFunction> descs = null;
    try {
        descs = t.findByNamedQuery("QUERY_GETFUNCTIONDESC", new String[] { pname, cat, fname });
        //System.out.println(t.toString());
        t.initialize(descs);
    } catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);
            else if (i == PermissionException.ProxyNotAuthorized
                    || i == PermissionException.ServerNotAuthorized)
                throw new PermissionException(errorMessage, i);
            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    if (descs == null || descs.size() == 0)
        throw new AuthorizationException("error retrieving functions desc for func " + userName);

    PickableFunction f = descs.iterator().next();
    return (f.getDescription());
}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

/**
 * Select Qualifiers for which userName is authorized. 
 *
 * @param userName user's kerberos Id/*w w w .  j  a va 2  s .co m*/
 * @param function_name funtion name
 * @throws  InvalidInputException if qualifier type code is NULL or if the code is more than 4 characters long
 * @throws  ObjectNotFoundException If no Qualifier is found 
 * @throws  AuthorizationException  in case of hibernate error   
 */
public Set<PickableQualifier> listPickableQualifiers(String userName, String function_name)
        throws InvalidInputException, PermissionException, AuthorizationException {
    if (null == userName || null == function_name)
        throw new InvalidInputException();

    String pname = userName.trim().toUpperCase();
    String fname = function_name.trim().toUpperCase();

    if (pname.length() <= 0 || fname.length() <= 0)
        throw new InvalidInputException();

    HibernateTemplate t = getHibernateTemplate();
    Collection quals = null;
    try {
        quals = t.findByNamedQuery("PICKABLE_QUALIFIER_LIST",
                new String[] { pname, fname, pname, fname, pname, fname, pname, fname, pname, fname });
        //System.out.println(t.toString());
        t.initialize(quals);
    }

    catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else if (i == PermissionException.ProxyNotAuthorized
                    || i == PermissionException.ServerNotAuthorized)
                throw new PermissionException(errorMessage, i);
            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    if (quals == null)
        throw new AuthorizationException("error retrieving qualifiers for user " + userName);

    Set<PickableQualifier> qualSet = new HashSet<PickableQualifier>(quals);
    return qualSet;
}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

/**
 * Select Qualifiers for which userName is authorized. 
 *
 * @param userName user's kerberos Id//from   w ww. j av  a2 s .  c  o m
 * @param function_name funtion name
 * @throws  InvalidInputException if qualifier type code is NULL or if the code is more than 4 characters long
 * @throws  ObjectNotFoundException If no Qualifier is found 
 * @throws  AuthorizationException  in case of hibernate error   
 */
public String getQualifierXML(String userName, String function_name, String qualifier_type)
        throws InvalidInputException, PermissionException, AuthorizationException {
    if (null == userName || null == function_name)
        throw new InvalidInputException();

    StringBuffer xmlBuff = new StringBuffer();
    Iterator qIt = null;
    PickableQualifier xmlqual = null;
    String pname = userName.trim().toUpperCase();
    String fname = function_name.trim().toUpperCase();
    String qtype = "ZLEVELS_" + qualifier_type.trim().toUpperCase();

    total_qualifiers = 0;

    if (pname.length() <= 0 || fname.length() <= 0)
        throw new InvalidInputException();

    HibernateTemplate t1 = getHibernateTemplate();
    Collection<LevelCount> lc = null;

    try {
        lc = t1.findByNamedQuery("GET_LEVEL_FOR_QUAL_TYPE", new String[] { qtype, qtype });
        //System.out.println(t1.toString());
        t1.initialize(lc);
    }

    catch (DataAccessException e) {
        if (e.getCause() instanceof SQLException) {
            SQLException se = (SQLException) e.getCause();
            int i = se.getErrorCode();
            String msg = se.getMessage();
            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(msg, i);

            else if (i == PermissionException.ProxyNotAuthorized
                    || i == PermissionException.ServerNotAuthorized)
                throw new PermissionException(msg, i);
            else
                throw new AuthorizationException(se.getMessage() + "\n" + "Error Code: " + se.getErrorCode()
                        + "\n" + " Cause: " + se.getCause());
        } else
            throw new AuthorizationException(e.getMessage());
    }

    int val = Integer.parseInt(lc.iterator().next().getValue()) - 1;

    HibernateTemplate t = getHibernateTemplate();
    Collection<PickableQualifier> quals = null;

    try {
        quals = t.findByNamedQuery("PICKABLE_QUALIFIER_LIST", new String[] { pname, fname });
        //System.out.println(t.toString());
        t.initialize(quals);
    }

    catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else if (i == PermissionException.ProxyNotAuthorized
                    || i == PermissionException.ServerNotAuthorized)
                throw new PermissionException(errorMessage, i);
            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    xmlBuff.append("<qualifiers>");

    if (quals == null)
        throw new AuthorizationException("error retrieving qualifiers for user " + userName);

    //Set<PickableQualifier> qualSet = new HashSet<PickableQualifier>(quals);
    //System.out.println(quals.size());
    //System.out.println(qualSet.size());

    //qIt = qualSet.iterator();
    qIt = quals.iterator();

    while (qIt.hasNext()) {
        total_qualifiers++;
        //System.out.println("Total = " + total_qualifiers);
        xmlqual = (PickableQualifier) qIt.next();
        xmlBuff.append("<qualifier>");
        xmlBuff.append("<qid>");
        xmlBuff.append(xmlqual.getId().getId());
        xmlBuff.append("</qid>");
        xmlBuff.append("<expanded>");
        xmlBuff.append("true");
        xmlBuff.append("</expanded>");
        xmlBuff.append("<qcode>");
        xmlBuff.append(cleanup(xmlqual.getQcode(), false));
        xmlBuff.append("</qcode>");
        xmlBuff.append("<qname>");
        xmlBuff.append(cleanup(xmlqual.getId().getName(), false));
        xmlBuff.append("</qname>");
        xmlBuff.append("<hasChild>");
        xmlBuff.append(cleanup(xmlqual.getId().getHasChild().toString(), false));
        xmlBuff.append("</hasChild>");
        if (xmlqual.getId().getHasChild() && total_qualifiers < 2000) {
            xmlBuff.append("<qchildren>");
            xmlBuff.append(getChildrenXML(xmlqual.getId().getId().toString(), 1, val));
            xmlBuff.append("</qchildren>");
        }
        xmlBuff.append("</qualifier>");
    }

    xmlBuff.append("</qualifiers>");
    //System.out.println("Final Buffer = " + xmlBuff.toString());
    return xmlBuff.toString();
}