List of usage examples for org.springframework.dao IncorrectResultSizeDataAccessException getMessage
@Override
@Nullable
public String getMessage()
From source file:com.sfs.whichdoctor.dao.PersonDAOImpl.java
/** * Load a PersonBean for a specified personId using the load options * provided. A boolean parameter identifies whether to use the default * reader connection or optional writer connection datasource * * @param personId the person id// ww w. j a v a 2s. c o m * @param loadDetails the load details * @param useWriterConn the use writer conn * * @return the person bean * * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") private PersonBean load(final int personId, final BuilderBean loadDetails, final boolean useWriterConn) throws WhichDoctorDaoException { PersonBean person = null; final String loadPersonId = getSQL().getValue("person/load") + " AND people.PersonId = ?"; JdbcTemplate jdbcTemplate = this.getJdbcTemplateReader(); if (useWriterConn) { jdbcTemplate = this.getJdbcTemplateWriter(); } try { person = (PersonBean) jdbcTemplate.queryForObject(loadPersonId, new Object[] { personId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadPerson(rs, loadDetails); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } return person; }
From source file:com.sfs.whichdoctor.dao.PersonDAOImpl.java
/** * Generate personal identifier./*from w w w .j a v a 2 s .c o m*/ * * @return the personal identifier */ private final int generatePersonIdentifier() { int personalIdentifier = 0; try { personalIdentifier = this.getJdbcTemplateReader().queryForInt( this.getSQL().getValue("person/findMaxPersonIdentifier"), new Object[] { this.personIdentifierClass }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } boolean unique = false; while (!unique) { personalIdentifier++; try { this.getJdbcTemplateReader().queryForInt(this.getSQL().getValue("person/uniquePersonIdentifier"), new Object[] { personalIdentifier }); } catch (IncorrectResultSizeDataAccessException ie) { unique = true; } } return personalIdentifier; }
From source file:eionet.meta.service.VocabularyServiceImpl.java
/** * {@inheritDoc}/*from w w w. ja v a 2 s . c o m*/ */ @Override public VocabularyConcept getVocabularyConcept(int vocabularyFolderId, String conceptIdentifier, boolean emptyAttributes) throws ServiceException { try { VocabularyConcept result = vocabularyConceptDAO.getVocabularyConcept(vocabularyFolderId, conceptIdentifier); int conceptId = result.getId(); Map<Integer, List<List<DataElement>>> vocabularyConceptsDataElementValues = dataElementDAO .getVocabularyConceptsDataElementValues(vocabularyFolderId, new int[] { conceptId }, emptyAttributes); result.setElementAttributes(vocabularyConceptsDataElementValues.get(conceptId)); return result; } catch (IncorrectResultSizeDataAccessException e) { ServiceException se = new ServiceException( "Vocabulary concept \"" + conceptIdentifier + "\" not found!", e); se.setErrorParameter(ErrorActionBean.ERROR_TYPE_KEY, ErrorActionBean.ErrorType.NOT_FOUND_404); throw se; } catch (Exception e) { throw new ServiceException("Failed to get vocabulary concept: " + e.getMessage(), e); } }
From source file:eionet.meta.service.VocabularyServiceImpl.java
/** * {@inheritDoc}//from w w w .j a va2 s . c o m */ @Override public VocabularyFolder getVocabularyFolder(String folderName, String identifier, boolean workingCopy) throws ServiceException { try { VocabularyFolder result = vocabularyFolderDAO.getVocabularyFolder(folderName, identifier, workingCopy); // Load attributes List<List<SimpleAttribute>> attributes = attributeDAO.getVocabularyFolderAttributes(result.getId(), true); result.setAttributes(attributes); return result; } catch (IncorrectResultSizeDataAccessException e) { ServiceException se = new ServiceException("Vocabulary set \"" + folderName + "\" or vocabulary identifier \"" + identifier + "\" not found!", e); se.setErrorParameter(ErrorActionBean.ERROR_TYPE_KEY, ErrorActionBean.ErrorType.NOT_FOUND_404); throw se; } catch (Exception e) { String parameters = "folderName=" + String.valueOf(folderName) + "; identifier=" + String.valueOf(identifier) + "; workingCopy=" + workingCopy; throw new ServiceException("Failed to get vocabulary folder (" + parameters + "):" + e.getMessage(), e); } }
From source file:org.cloudfoundry.identity.uaa.scim.endpoints.ScimGroupEndpoints.java
@RequestMapping(value = { "/Groups/{groupId}" }, method = RequestMethod.PUT) @ResponseBody/*from ww w.jav a 2s .c o m*/ public ScimGroup updateGroup(@RequestBody ScimGroup group, @PathVariable String groupId, @RequestHeader(value = "If-Match", required = false) String etag, HttpServletResponse httpServletResponse) { if (etag == null) { throw new ScimException("Missing If-Match for PUT", HttpStatus.BAD_REQUEST); } logger.debug("updating group: " + groupId); int version = getVersion(groupId, etag); group.setVersion(version); ScimGroup existing = getGroup(groupId, httpServletResponse); try { group.setZoneId(IdentityZoneHolder.get().getId()); ScimGroup updated = dao.update(groupId, group); if (group.getMembers() != null && group.getMembers().size() > 0) { membershipManager.updateOrAddMembers(updated.getId(), group.getMembers()); } else { membershipManager.removeMembersByGroupId(updated.getId()); } updated.setMembers(membershipManager.getMembers(updated.getId(), null, false)); addETagHeader(httpServletResponse, updated); return updated; } catch (IncorrectResultSizeDataAccessException ex) { logger.error("Error updating group, restoring to previous state"); // restore to correct state before reporting error existing.setVersion(getVersion(groupId, "*")); dao.update(groupId, existing); throw new ScimException(ex.getMessage(), ex, HttpStatus.CONFLICT); } catch (ScimResourceNotFoundException ex) { logger.error("Error updating group, restoring to previous state: " + existing); // restore to correct state before reporting error existing.setVersion(getVersion(groupId, "*")); dao.update(groupId, existing); throw new ScimException(ex.getMessage(), ex, HttpStatus.BAD_REQUEST); } }