List of usage examples for org.springframework.dao DataAccessException getCause
public synchronized Throwable getCause()
From source file:edu.jhuapl.openessence.datasource.jdbc.entry.JdbcOeDataEntrySource.java
/** * Executes UPDATE SQL Statment using Spring's JdbcTemplate. * * @param tablename table to insert values into * @param replRecord use values of replacement record within the UPDATE statement * @param pkIds_ValuesMap maps dimensionID to the value. In this case, the dimensions will correspond to PK columns *///from w w w . ja va 2s . co m private void editableUpdateStatement(String tablename, TableAwareQueryRecord replRecord, Map<String, Object> pkIds_ValuesMap) throws OeDataSourceAccessException { try { jdbcTemplate .update(new MultiTableUpdatePreparedStatementCreator(tablename, replRecord, pkIds_ValuesMap)); } catch (DataAccessException e) { if (e.getCause() instanceof UpdateException) { log.info(e.getMessage()); } else { throw new OeDataSourceAccessException(e); } } }
From source file:edu.mit.isda.permitservice.dataobjects.GeneralSelection.java
/** * retrieves a Criteria Set by selection ID and certificate username. * * @param selectionID/*from w w w . jav a 2s.c om*/ * @param username * @return {@link Category} matching the category code * @throws InvalidInputException If the category code is NULL or more than 4 characters long * @throws ObjectNotFoundException If no category is found in the database matching the category code * @throws AuthorizationException in case of hibernate error */ public Collection<Criteria> getCriteriaSet(String selectionID, String userName) throws InvalidInputException, ObjectNotFoundException, AuthorizationException { if (null == userName) throw new InvalidInputException(); String name = userName.trim().toUpperCase(); if (name.length() <= 0) throw new InvalidInputException(); HibernateTemplate t = getHibernateTemplate(); Collection crits = null; try { crits = t.findByNamedQuery("GET_CRITERIA", new String[] { name, selectionID }); t.initialize(crits); } catch (DataAccessException e) { Exception re = (Exception) e.getCause(); re.printStackTrace(); 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()); } catch (Exception e) { e.printStackTrace(); } if (crits == null) { throw new AuthorizationException("error retrieving viewable categories"); } return crits; }
From source file:edu.mit.isda.permitservice.dataobjects.GeneralSelection.java
/** * retrieves a selection list by certificate username. * * @param username// w w w.ja v a 2 s . com * @return {@link Category} matching the category code * @throws InvalidInputException If the category code is NULL or more than 4 characters long * @throws ObjectNotFoundException If no category is found in the database matching the category code * @throws AuthorizationException in case of hibernate error */ public Collection<SelectionList> getSelectionList(String userName) throws InvalidInputException, ObjectNotFoundException, AuthorizationException { if (null == userName) { throw new InvalidInputException(); } String name = userName.trim().toUpperCase(); if (name.length() <= 0) throw new InvalidInputException(); HibernateTemplate t = getHibernateTemplate(); Collection crits = null; try { crits = t.findByNamedQuery("SELECTION_LIST", new String[] { name, name }); t.initialize(crits); } catch (DataAccessException e) { Exception re = (Exception) e.getCause(); re.printStackTrace(); 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()); } } catch (Exception e) { e.printStackTrace(); System.out.println(e.getMessage()); } if (crits == null) { throw new AuthorizationException("error retrieving viewable categories"); } return crits; }
From source file:edu.mit.isda.permitservice.dataobjects.GeneralSelection.java
/** * retrieve a set of Authorizations based on a criteria list * * @param criteriaXML XML string containing criteria information * @return a set of {@link Authorization} matching the specified criteria * @throws InvalidInputException If any of the parameters is NULL * @throws ObjectNotFoundException If no authorizations is found matching the criteria * @throws AuthorizationException in case of hibernate error *//*from ww w . j a v a 2 s .com*/ @SuppressWarnings("unchecked") public Collection<Authorization> listAuthorizationsByCriteria(String[] criteria) throws InvalidInputException, ObjectNotFoundException, PermissionException, AuthorizationException { if (criteria == null) throw new InvalidInputException(); HibernateTemplate t = getHibernateTemplate(); List alist = new ArrayList(); Collection authorizations = null; for (int i = 0; i < criteria.length; i++) { log.debug("Criteria " + i + ":" + criteria[i]); } try { authorizations = t.findByNamedQuery("LISTAUTHSBYCRIT_RAW", criteria); // authorizations = t.findByNamedQuery("LISTAUTHSBYCRIT_SP", obj); t.initialize(authorizations); } 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()); } return authorizations; }
From source file:edu.mit.isda.permitservice.dataobjects.GeneralSelection.java
/** * retrieve a set of people based on a kerberos or last name * * @param criteriaXML XML string containing criteria information * @return a set of {@link Authorization} matching the specified criteria * @throws InvalidInputException If any of the parameters is NULL * @throws ObjectNotFoundException If no authorizations is found matching the criteria * @throws AuthorizationException in case of hibernate error *//*from ww w. j ava 2 s.c o m*/ @SuppressWarnings("unchecked") public Collection<PersonRaw> listPersonRaw(String name, String search, String sort, String filter1, String filter2, String filter3) throws InvalidInputException, ObjectNotFoundException, PermissionException, AuthorizationException { if (name == null) throw new InvalidInputException(); HibernateTemplate t = getHibernateTemplate(); List alist = new ArrayList(); String last_only = "%"; String kerb_only = "%"; String both = "%"; String mitId = name; if (search.equals("kerberos")) { kerb_only = name; } else if (search.equals("last")) { last_only = name; } else if (search.equals("both")) { both = name; } if (name.endsWith("%")) { mitId = name.substring(0, name.length() - 1).trim(); } else { mitId = name.trim(); } System.out.println("******************* LAST: " + last_only); System.out.println("******************* KERB ID: " + kerb_only); System.out.println("******************* BOTH: " + both); System.out.println("******************* MIT ID: " + mitId); Collection people = null; try { if (sort.equals("last")) people = t.findByNamedQuery("QUICK_PERSON", new String[] { last_only, kerb_only, both, both, mitId, filter1, filter2, filter3 }); else if (sort.equals("kerberos")) people = t.findByNamedQuery("QUICK_PERSON_KERBSORT", new String[] { last_only, kerb_only, both, both, mitId, filter1, filter2, filter3 }); else if (sort.equals("type")) people = t.findByNamedQuery("QUICK_PERSON_TYPESORT", new String[] { last_only, kerb_only, both, both, mitId, filter1, filter2, filter3 }); else { people = t.findByNamedQuery("QUICK_PERSON", new String[] { last_only, kerb_only, both, both, mitId, filter1, filter2, filter3 }); } t.initialize(people); } 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()); } return people; }
From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java
/** * retrieve a set of Authorizations by a person's kerberosId * * @param userName user's kerberos Id// www . j a v a 2 s . c o m * @param category Authorization Category code, such as "SAP" * @param isActive if you are only interested in authorizations that are currently active, use Boolean.TRUE, otherwise, use Boolean.FALSE * @param willExpand if you want to expand the qualifier to get the implicit authorization or not * @param proxyUserName the user who is executing this query * @return a set of {@link Authorization} matching the specified criteria * @throws InvalidInputException If any of the parameters is NULL * @throws ObjectNotFoundException If no authorizations is found matching the criteria * @throws AuthorizationException in case of hibernate error */ @SuppressWarnings("unchecked") public Set<Authorization> listAuthorizationsByPerson(String userName, String category, Boolean isActive, Boolean willExpand, String applicationName, String proxyUserName) throws InvalidInputException, ObjectNotFoundException, PermissionException, AuthorizationException { if (userName == null || category == null || isActive == null || willExpand == null || applicationName == null || proxyUserName == null) throw new InvalidInputException(); String pname = userName.trim().toUpperCase(); String categoryCode = category.trim().toUpperCase(); String aname = applicationName.trim().toUpperCase(); String pUser = proxyUserName.trim().toUpperCase(); //if (pname.length() <= 0 || categoryCode.length()<=0 || aname.length()<=0 || pUser.length() <=0) if (pname.length() <= 0 || aname.length() <= 0 || pUser.length() <= 0) throw new InvalidInputException(); if (categoryCode.length() > 0) { while (categoryCode.length() < 4) { categoryCode += " "; } } String active = isActive ? "Y" : "N"; String expand = willExpand ? "Y" : "N"; HibernateTemplate t = getHibernateTemplate(); Collection authorizations = null; try { authorizations = t.findByNamedQuery("LISTAUTHSBYPERSON_SP", new String[] { aname, pUser, pname, categoryCode, expand, active }); t.initialize(authorizations); } 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 (authorizations == null) throw new AuthorizationException("error retrieving authorizations for user " + userName); Set<Authorization> authSet = new HashSet<Authorization>(authorizations); return authSet; }
From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java
/** * retrieve a set of Authorizations by a person's kerberosId *//from w w w .j av a 2 s . co m * @param userName user's kerberos Id * @param category Authorization Category code, such as "SAP" * @param isActive if you are only interested in authorizations that are currently active, use Boolean.TRUE, otherwise, use Boolean.FALSE * @param willExpand if you want to expand the qualifier to get the implicit authorization or not * @param proxyUserName the user who is executing this query * @return a set of {@link Authorization} matching the specified criteria * @throws InvalidInputException If any of the parameters is NULL * @throws ObjectNotFoundException If no authorizations is found matching the criteria * @throws AuthorizationException in case of hibernate error */ @SuppressWarnings("unchecked") public Collection<AuthorizationExt> listAuthByPersonExtend1(String userName, String category, Boolean isActive, Boolean willExpand, String applicationName, String proxyUserName, String realOrImplied, String function_name, String function_id, String function_qualifier_type, String qualifier_code, String qualifier_id, String base_qual_code, String base_qual_id, String parent_qual_code, String parent_qual_id) throws InvalidInputException, ObjectNotFoundException, PermissionException, AuthorizationException { if (userName == null || category == null || isActive == null || willExpand == null || applicationName == null || proxyUserName == null) throw new InvalidInputException(); String pname = userName.trim().toUpperCase(); String categoryCode = category.trim().toUpperCase(); String aname = applicationName.trim().toUpperCase(); String pUser = proxyUserName.trim().toUpperCase(); String rori = "B"; if (null != realOrImplied) { rori = realOrImplied.trim().toUpperCase(); } //if (pname.length() <= 0 || categoryCode.length()<=0 || aname.length()<=0 || pUser.length() <=0) if (pname.length() <= 0 || aname.length() <= 0 || pUser.length() <= 0) throw new InvalidInputException(); if (categoryCode.length() > 0) { while (categoryCode.length() < 4) { categoryCode += " "; } } String active = isActive ? "Y" : "N"; String expand = willExpand ? "Y" : "N"; HibernateTemplate t = getHibernateTemplate(); Collection authorizations = null; try { authorizations = t.findByNamedQuery("LISTAUTHBYPERSON_EXT", new String[] { aname, pUser, pname, categoryCode, expand, active, rori, function_name, function_id, function_qualifier_type, qualifier_code, qualifier_id, base_qual_code, base_qual_id, parent_qual_code, parent_qual_id }); t.initialize(authorizations); } 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 (authorizations == null) throw new AuthorizationException("error retrieving authorizations for user " + userName); return authorizations; }
From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java
/** * retrieve a set of Authorizations by a person's kerberosId * * @param userName user's kerberos Id/*from w ww . ja v a2 s . c o m*/ * @param category Authorization Category code, such as "SAP" * @param isActive if you are only interested in authorizations that are currently active, use Boolean.TRUE, otherwise, use Boolean.FALSE * @param willExpand if you want to expand the qualifier to get the implicit authorization or not * @param proxyUserName the user who is executing this query * @return a set of {@link Authorization} matching the specified criteria * @throws InvalidInputException If any of the parameters is NULL * @throws ObjectNotFoundException If no authorizations is found matching the criteria * @throws AuthorizationException in case of hibernate error */ @SuppressWarnings("unchecked") public Collection<AuthorizationRaw> listAuthorizationsByPersonRaw(String userName, String category, Boolean isActive, Boolean willExpand, String applicationName, String proxyUserName) throws InvalidInputException, ObjectNotFoundException, PermissionException, AuthorizationException { if (userName == null || category == null || isActive == null || willExpand == null || applicationName == null || proxyUserName == null) throw new InvalidInputException(); String pname = userName.trim().toUpperCase(); String categoryCode = category.trim().toUpperCase(); String aname = applicationName.trim().toUpperCase(); String pUser = proxyUserName.trim().toUpperCase(); //if (pname.length() <= 0 || categoryCode.length()<=0 || aname.length()<=0 || pUser.length() <=0) if (pname.length() <= 0 || aname.length() <= 0 || pUser.length() <= 0) throw new InvalidInputException(); if (categoryCode.length() > 0) { while (categoryCode.length() < 4) { categoryCode += " "; } } String active = isActive ? "Y" : "N"; String expand = willExpand ? "Y" : "N"; HibernateTemplate t = getHibernateTemplate(); Collection authorizations = null; try { authorizations = t.findByNamedQuery("LISTAUTHRAW", new String[] { aname, pUser, pname, categoryCode, expand, active }); t.initialize(authorizations); } 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 (authorizations == null) throw new AuthorizationException("error retrieving authorizations for user " + userName); return authorizations; }
From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java
/** * retrieves all the Categories in the database * * @return all the {@link Category} in the database * @throws ObjectNotFoundException If no category is found * @throws AuthorizationException in case of hibernate error *//*from w ww. j a v a 2 s . co m*/ @SuppressWarnings("unchecked") public Set<Category> listCategories() throws ObjectNotFoundException, AuthorizationException { List l = null; HibernateTemplate t = getHibernateTemplate(); try { l = t.find("from Category c"); } 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); throw new AuthorizationException(errorMessage); } else throw new AuthorizationException(e.getLocalizedMessage()); } if (l == null) throw new ObjectNotFoundException("No Categories found in database"); Set<Category> catSet = new HashSet<Category>(l); return catSet; }
From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java
/** * retrieves all the QualifierTypes in the database * * @return all the {@link QualifierType} in the database * @throws ObjectNotFoundException If no QualifierType is found * @throws AuthorizationException in case of hibernate error *//* www. j av a2 s . c o m*/ @SuppressWarnings("unchecked") public Set<QualifierType> listQualifierTypes() throws ObjectNotFoundException, AuthorizationException { List l = null; HibernateTemplate t = getHibernateTemplate(); try { l = t.find("from QualifierType c"); } 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) { String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode(); throw new AuthorizationException(errorMessage); } else throw new AuthorizationException(e.getMessage()); } if (l == null) throw new ObjectNotFoundException("No Qualifier Type found in database"); Set<QualifierType> qSet = new HashSet<QualifierType>(l); return qSet; }