Example usage for org.springframework.dao DataAccessException getMessage

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

Introduction

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

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

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;/*from ww  w  .j a  v a2s  . c  om*/
    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;/*from  w ww  . j a v  a  2s  .  c o m*/
    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

/**
  * Create a batch of new authorizations
  *//from w  w w.  j ava2s .c o  m
  * @param userName user's kerberos Id
  * @param kerberos_name kerberos name to which new authorizations are assigned
  * @param authIDs comma delimited string of authorization IDs to create
  * @return string of authorization IDs that were updated
  * @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 batchCreate(String userName, String appName, String kerberos_name, String authIDs)
        throws InvalidInputException, PermissionException, AuthorizationException, DataAccessException {
    if (null == userName || null == authIDs || null == kerberos_name)
        throw new InvalidInputException();

    String pname = userName.trim().toUpperCase();
    String kname = kerberos_name.trim().toUpperCase();
    int noChange = 0;
    int notAuth = 0;
    int kerbError = 0;
    int unknown = 0;
    int updated = 0;
    String retString = new String();

    String[] ids = authIDs.split(",");

    String idString = new String();
    boolean success = true;

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

    ApplicationContext ctx;
    Map results = null;
    String[] paths = { "rolesApplicationContext.xml" };
    ctx = new ClassPathXmlApplicationContext(paths);

    DataSource datasource = null;
    String datasourceID = "commonsDataSource";
    datasource = (DataSource) ctx.getBean(datasourceID);

    //BatchCreateAuthProc proc = new BatchCreateAuthProc(datasource);
    for (int i = 0; i < ids.length; i++) {
        try {
            results = batchActionDao.batchCreate(appName, pname, kname, ids[i]);
            if (null != results.get("modified_by") && null != results.get("modified_date")
                    && null != results.get("authorization_id")) {
                idString += results.get("authorization_id").toString() + ",";
                updated++;
            } else {
                success = false;
            }
        } catch (DataAccessException e) {
            success = false;
            System.out.println(e.getMessage());
            if ((e.getMessage().indexOf("ORA-20014") >= 0) || (e.getMessage().indexOf("ORA-20003") >= 0)) {
                notAuth++;
            } else if (e.getMessage().indexOf("ORA-20007") >= 0) {
                noChange++;
            } else if (e.getMessage().indexOf("ORA-20030") >= 0) {
                kerbError++;
            } else {
                unknown++;
            }
        }
    }

    if (success) {
        return "All " + updated + " authorization(s) created successfully";
    } else if (idString.length() == 0) {

        if (updated > 0)
            retString += updated + " authorization(s) successfully created; ";
        if (notAuth > 0) {
            retString += notAuth + " authorization(s) not created  because you  are not authorized; ";
        }
        if (kerbError > 0) {
            retString += kerbError + " authorization(s) were not created because Kerberos name (" + kname
                    + ") does not exist; ";
        }
        if (unknown > 0) {
            retString += unknown + " authorization(s) not created  for unknown reason; ";
        }
        if (noChange > 0) {
            retString += noChange + " authorization(s) not created  because the authorization(s) already exist";

        }
        retString += ".";
        return retString;

    } else {
        if (updated > 0)
            retString += updated + " authorization(s) successfully created; ";
        if (notAuth > 0) {
            retString += notAuth + " authorization(s) not created  because you  are not authorized; ";
        }
        if (kerbError > 0) {
            retString += kerbError + " authorization(s) were not created because Kerberos name (" + kname
                    + ") does not exist;";
        }
        if (unknown > 0) {
            retString += unknown + " authorization(s) not created  for unknown reason; ";
        }
        if (noChange > 0) {
            retString += noChange
                    + " authorization(s) not created  because the authorization(s) already exist.";

        }
        return retString;
    }
}

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

/**
  * Save criteria//from   w ww.  j  a  va  2 s.  com
  *
  * @param userName user's kerberos Id
  * @param appName application Id
  * @param selection_id selection id of criteria
  * @param criteria_list list of criteria
  * @param value_list list of values
  * @param apply_list list of Y/N values for apply
  * @return string of authorization IDs that were updated
  * @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 saveCriteria(String userName, String appName, String selection_id, String criteria_list,
        String value_list, String apply_list) throws InvalidInputException {
    if (null == userName || null == appName || null == selection_id || null == criteria_list
            || null == value_list || null == apply_list)
        throw new InvalidInputException();

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

    String[] crits = criteria_list.split(",");
    String[] values = value_list.split(",");
    String[] applys = apply_list.split(",");

    String idString = new String();
    boolean success = true;

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

    ApplicationContext ctx;
    Map results = null;
    String[] paths = { "rolesApplicationContext.xml" };
    ctx = new ClassPathXmlApplicationContext(paths);

    DataSource datasource = null;
    String datasourceID = "commonsDataSource";
    datasource = (DataSource) ctx.getBean(datasourceID);

    SaveCriteriaProc proc = new SaveCriteriaProc(datasource);
    try {
        for (int i = 0; i < crits.length; i++) {
            results = proc.execute(appName, selection_id, crits[i], pname, applys[i], values[i]);
        }
    } catch (DataAccessException e) {
        System.out.println(e.getMessage());
        success = false;
    }

    if (success) {
        return "Criteria set successfully saved";
    } else {
        return "Criteria set could not saved successfully";
    }
}

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  .  j  a  v a  2 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<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.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<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//  w ww .j  av a2  s.  c o m
 * @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/*from  w w  w. j a v a  2s .  c  om*/
* @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 av a  2s  .c om*/
 * @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/*  ww  w  .  j  a  va2s .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();
}