Java Code Examples for org.springframework.dao.DataAccessException.getMessage()

The following are Jave code examples for showing how to use getMessage() of the org.springframework.dao.DataAccessException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: McService.java   View Source Code Vote up 6 votes
@Override
   public McQueUsr createMcUser(Long toolSessionID) throws McApplicationException {
try {
    HttpSession ss = SessionManager.getSession();
    UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
    Long userId = toolUser.getUserID().longValue();
    String userName = toolUser.getLogin();
    String fullName = toolUser.getFirstName() + " " + toolUser.getLastName();
    McSession mcSession = getMcSessionById(toolSessionID.longValue());

    McQueUsr user = new McQueUsr(userId, userName, fullName, mcSession, new TreeSet());
    mcUserDAO.saveMcUser(user);

    return user;
} catch (DataAccessException e) {
    throw new McApplicationException("Exception occured when lams is creating mc QueUsr: " + e.getMessage(), e);
}
   }
 
Example 2
Project: spring-backend-boilerplate   File: UserDetailsAuthenticationProviderImpl.java   View Source Code Vote up 6 votes
/**
 * Implementation of an abstract method defined in the base class. The
 * retrieveUser() method is called by authenticate() method of the base
 * class. The latter is called by the AuthenticationManager.
 */
@Override
protected final UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication)
		throws AuthenticationException {
	UserDetails details;
	try {
		details = this.getUserDetailsService().loadUserByUsername(username);
		authentication.setDetails(details);
	}
	catch (DataAccessException repositoryProblem) {
		throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
	}

	if (details == null) {
		throw new AuthenticationServiceException(
				"UserDetailsService returned null, which is an interface contract violation");
	}
	return details;
}
 
Example 3
Project: spring-backend-boilerplate   File: UserDetailsAuthenticationProviderImpl.java   View Source Code Vote up 6 votes
/**
 * Implementation of an abstract method defined in the base class. The
 * retrieveUser() method is called by authenticate() method of the base
 * class. The latter is called by the AuthenticationManager.
 */
@Override
protected final UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication)
		throws AuthenticationException {
	UserDetails details;
	try {
		details = this.getUserDetailsService().loadUserByUsername(username);
		authentication.setDetails(details);
	}
	catch (DataAccessException repositoryProblem) {
		throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
	}

	if (details == null) {
		throw new AuthenticationServiceException(
				"UserDetailsService returned null, which is an interface contract violation");
	}
	return details;
}
 
Example 4
Project: lams   File: VoteService.java   View Source Code Vote up 5 votes
@Override
   public List<VoteUsrAttempt> getAttemptsForUserAndQuestionContent(final Long userUid, final Long questionUid) {
try {
    return voteUsrAttemptDAO.getAttemptsForUserAndQuestionContent(userUid, questionUid);
} catch (DataAccessException e) {
    throw new VoteApplicationException(
	    "Exception occured when lams is getting vote voteUsrRespDAO by user id and que content id: "
		    + e.getMessage(),
	    e);
}
   }
 
Example 5
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public void updateMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException {
try {
    mcUserDAO.updateMcUser(mcQueUsr);
} catch (DataAccessException e) {
    throw new McApplicationException("Exception occured when lams is updating mc QueUsr: " + e.getMessage(), e);
}
   }
 
Example 6
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionUid) throws McApplicationException {
try {
    return mcUserDAO.getMcUserBySession(queUsrId, mcSessionUid);
} catch (DataAccessException e) {
    throw new McApplicationException("Exception occured when lams is getting mc QueUsr: " + e.getMessage(), e);
}
   }
 
Example 7
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public McQueUsr getMcUserByUID(Long uid) throws McApplicationException {
try {
    return mcUserDAO.getMcUserByUID(uid);
} catch (DataAccessException e) {
    throw new McApplicationException(
	    "Exception occured when lams is getting the mc QueUsr by uid." + e.getMessage(), e);
}
   }
 
Example 8
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public void updateMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException {
try {
    mcUsrAttemptDAO.updateMcUsrAttempt(mcUsrAttempt);
} catch (DataAccessException e) {
    throw new McApplicationException("Exception occured when lams is updating mc UsrAttempt: " + e.getMessage(),
	    e);
}
   }
 
Example 9
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public List refreshQuestionContent(final Long mcContentId) throws McApplicationException {
try {
    return mcQueContentDAO.refreshQuestionContent(mcContentId);
} catch (DataAccessException e) {
    throw new McApplicationException(
	    "Exception occured when lams is refreshing  mc question content: " + e.getMessage(), e);
}

   }
 
Example 10
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public void removeMcQueContent(McQueContent mcQueContent) throws McApplicationException {
try {
    mcQueContentDAO.removeMcQueContent(mcQueContent);
} catch (DataAccessException e) {
    throw new McApplicationException(
	    "Exception occured when lams is removing mc question content: " + e.getMessage(), e);
}
   }
 
Example 11
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public List<McOptionDTO> getOptionDtos(Long mcQueContentId) throws McApplicationException {
try {
    return mcOptionsContentDAO.getOptionDtos(mcQueContentId);
} catch (DataAccessException e) {
    throw new McApplicationException(
	    "Exception occured when lams is populating candidate answers dto" + e.getMessage(), e);
}
   }
 
Example 12
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public McSession getMcSessionById(Long mcSessionId) throws McApplicationException {
try {
    return mcSessionDAO.getMcSessionById(mcSessionId);
} catch (DataAccessException e) {
    throw new McApplicationException(
	    "Exception occured when lams is retrieving by id mc session : " + e.getMessage(), e);
}
   }
 
Example 13
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public void updateMc(McContent mc) throws McApplicationException {
try {
    mcContentDAO.updateMcContent(mc);
} catch (DataAccessException e) {
    throw new McApplicationException(
	    "Exception occured when lams is updating" + " the mc content: " + e.getMessage(), e);
}
   }
 
Example 14
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public List<McOptsContent> findOptionsByQuestionUid(Long mcQueContentId) throws McApplicationException {
try {
    return mcOptionsContentDAO.findMcOptionsContentByQueId(mcQueContentId);
} catch (DataAccessException e) {
    throw new McApplicationException(
	    "Exception occured when lams is finding by que id" + " the mc options: " + e.getMessage(), e);
}
   }
 
Example 15
Project: lams   File: McService.java   View Source Code Vote up 5 votes
@Override
   public void updateMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException {
try {
    mcOptionsContentDAO.updateMcOptionsContent(mcOptsContent);
} catch (DataAccessException e) {
    throw new McApplicationException(
	    "Exception occured when lams is updating" + " the mc options content: " + e.getMessage(), e);
}
   }
 
Example 16
Project: lams   File: SubmitFilesService.java   View Source Code Vote up 5 votes
@Override
   public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) {
// pre-condition validation
if ((toolSessionId == null) || (toolContentId == null)) {
    throw new SubmitFilesException(
	    "Fail to create a submission session" + " based on null toolSessionId or toolContentId");
}

SubmitFilesService.log.debug("Start to create submission session based on toolSessionId["
	+ toolSessionId.longValue() + "] and toolContentId[" + toolContentId.longValue() + "]");
try {
    SubmitFilesContent submitContent = getSubmitFilesContent(toolContentId);
    if ((submitContent == null) || !toolContentId.equals(submitContent.getContentID())) {
	submitContent = new SubmitFilesContent();
	submitContent.setContentID(toolContentId);
    }
    SubmitFilesSession submitSession = new SubmitFilesSession();

    submitSession.setSessionID(toolSessionId);
    submitSession.setSessionName(toolSessionName);
    submitSession.setStatus(new Integer(SubmitFilesSession.INCOMPLETE));
    submitSession.setContent(submitContent);
    submitFilesSessionDAO.createSession(submitSession);
    SubmitFilesService.log.debug("Submit File session created");
} catch (DataAccessException e) {
    throw new SubmitFilesException(
	    "Exception occured when lams is creating" + " a submission Session: " + e.getMessage(), e);
}

   }
 
Example 17
Project: factcast   File: PGFactStore.java   View Source Code Vote up 5 votes
@Override
@Transactional
public void publish(@NonNull List<? extends Fact> factsToPublish) {
    try (Context time = publishLatency.time();) {

        List<Fact> copiedListOfFacts = Lists.newArrayList(factsToPublish);
        final int numberOfFactsToPublish = factsToPublish.size();

        log.trace("Inserting {} fact(s) in batches of {}", numberOfFactsToPublish, BATCH_SIZE);

        jdbcTemplate.batchUpdate(PGConstants.INSERT_FACT, copiedListOfFacts,
                BATCH_SIZE, (
                        statement, fact) -> {
                    statement.setString(1, fact.jsonHeader());
                    statement.setString(2, fact.jsonPayload());
                });

        // add serials to headers
        jdbcTemplate.batchUpdate(PGConstants.UPDATE_FACT_SERIALS, copiedListOfFacts,
                BATCH_SIZE, (
                        statement, fact) -> {
                    final String idMatch = "{\"id\":\"" + fact.id() + "\"}";
                    statement.setString(1, idMatch);
                });

        publishMeter.mark(numberOfFactsToPublish);

    } catch (DataAccessException sql) {

        publishFailedCounter.inc();
        // yikes
        if (sql instanceof DuplicateKeyException) {
            throw new IllegalArgumentException(sql.getMessage());
        } else {
            throw sql;
        }
    }
}