use of javax.persistence.NoResultException in project ORCID-Source by ORCID.
the class PeerReviewsControllerTest method testDeletePeerReview.
@Test
public void testDeletePeerReview() {
HttpSession session = mock(HttpSession.class);
when(servletRequest.getSession()).thenReturn(session);
PeerReviewForm form = getForm();
PeerReviewForm newForm = peerReviewsController.postPeerReview(form);
assertNotNull(newForm);
assertFalse(PojoUtil.isEmpty(newForm.getPutCode()));
String putCode = newForm.getPutCode().getValue();
peerReviewsController.deletePeerReviewJson(newForm);
try {
peerReviewsController.getPeerReviewJson(Long.valueOf(putCode));
fail();
} catch (NoResultException nre) {
}
}
use of javax.persistence.NoResultException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method disassociatePolicyGroupFromDomain.
@Override
@Transactional(readOnly = false)
public void disassociatePolicyGroupFromDomain(long domainId, long policyGroupId) throws ConfigurationStoreException {
validateState();
// make sure the domain exists
final Domain domain = domainDao.getDomain(domainId);
if (domain == null)
throw new ConfigurationStoreException("Domain with id " + domainId + " does not exist");
// make sure the policy group exists
final CertPolicyGroup policyGroup = this.getPolicyGroupById(policyGroupId);
if (policyGroup == null)
throw new ConfigurationStoreException("Policy group with id " + policyGroup + " does not exist");
try {
final Query select = entityManager.createQuery("SELECT cpr from CertPolicyGroupDomainReltn cpr where cpr.domain = ?1 " + " and cpr.certPolicyGroup = ?2 ");
select.setParameter(1, domain);
select.setParameter(2, policyGroup);
final CertPolicyGroupDomainReltn reltn = (CertPolicyGroupDomainReltn) select.getSingleResult();
entityManager.remove(reltn);
entityManager.flush();
} catch (NoResultException e) {
throw new ConfigurationStoreException("Association between domain id " + domainId + " and policy group id " + policyGroupId + " does not exist", e);
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to delete policy group from domain relation.", e);
}
}
use of javax.persistence.NoResultException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method getPolicyGroupById.
@Override
@Transactional(readOnly = true)
public CertPolicyGroup getPolicyGroupById(long id) throws ConfigurationStoreException {
validateState();
try {
final Query select = entityManager.createQuery("SELECT cpg from CertPolicyGroup cpg WHERE cpg.id = ?1");
select.setParameter(1, id);
final CertPolicyGroup rs = (CertPolicyGroup) select.getSingleResult();
// load relationships now as they were deferred by lazy loading
rs.getCertPolicyGroupReltn().size();
return rs;
} catch (NoResultException e) {
return null;
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to execute certificate policy group DAO query.", e);
}
}
use of javax.persistence.NoResultException in project cas by apereo.
the class GoogleAuthenticatorMongoDbTokenRepository method get.
@Override
public GoogleAuthenticatorToken get(final String uid, final Integer otp) {
try {
final Query query = new Query();
query.addCriteria(Criteria.where("userId").is(uid).and("token").is(otp));
final GoogleAuthenticatorToken r = this.mongoTemplate.findOne(query, GoogleAuthenticatorToken.class, this.collectionName);
return r;
} catch (final NoResultException e) {
LOGGER.debug("No record could be found for google authenticator id [{}]", uid);
}
return null;
}
use of javax.persistence.NoResultException in project cas by apereo.
the class MongoDbGoogleAuthenticatorTokenCredentialRepository method get.
@Override
public OneTimeTokenAccount get(final String username) {
try {
final Query query = new Query();
query.addCriteria(Criteria.where("username").is(username));
final GoogleAuthenticatorAccount r = this.mongoTemplate.findOne(query, GoogleAuthenticatorAccount.class, this.collectionName);
if (r != null) {
return decode(r);
}
} catch (final NoResultException e) {
LOGGER.debug("No record could be found for google authenticator id [{}]", username);
}
return null;
}
Aggregations