use of javax.persistence.NoResultException in project ORCID-Source by ORCID.
the class ClientDetailsManagerReadOnlyImpl method findByClientId.
@Override
public ClientDetailsEntity findByClientId(String clientId) {
ClientDetailsEntity result = null;
try {
Date lastModified = clientDetailsDao.getLastModified(clientId);
result = clientDetailsDao.findByClientId(clientId, lastModified.getTime());
if (result != null) {
if (!result.getClientId().equals(clientId))
LOGGER.error("Client getClientId doesn't match. Requested: " + clientId + " Returned: " + result.getClientId());
if (!result.getId().equals(clientId))
LOGGER.error("Client getId() doesn't match. Requested: " + clientId + " Returned: " + result.getId());
}
} catch (NoResultException nre) {
LOGGER.error("Error getting client by id:" + clientId, nre);
}
return result;
}
use of javax.persistence.NoResultException in project ORCID-Source by ORCID.
the class OrcidApiServiceDelegatorImpl method getOrcidSearchResultsResponse.
private Response getOrcidSearchResultsResponse(OrcidSearchResults orcidSearchResults, String query) {
if (orcidSearchResults != null) {
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2");
orcidMessage.setOrcidSearchResults(orcidSearchResults);
//TODO: THIS FAILS if there is no profile in SOLR (org.orcid.core.indexPublicProfile=false or via message-listener)
orcidMessageUtil.setSourceName(orcidMessage);
return Response.ok(orcidMessage).build();
} else {
Object[] params = { query };
throw new NoResultException(localeManager.resolveMessage("apiError.no_search_result.exception", params));
}
}
use of javax.persistence.NoResultException in project ORCID-Source by ORCID.
the class OrcidPropsDaoImpl method getValue.
@Override
public String getValue(String key) {
Assert.hasText(key, "Cannot look for empty keys");
Query query = entityManager.createQuery("SELECT value FROM OrcidPropsEntity WHERE key=:key");
query.setParameter("key", key);
try {
return (String) query.getSingleResult();
} catch (NonUniqueResultException nure) {
throw nure;
} catch (NoResultException nre) {
return null;
}
}
use of javax.persistence.NoResultException in project ORCID-Source by ORCID.
the class OrcidPropsDaoImpl method exists.
/**
* Checks if the given key exists in the OrcidPropsEntity table.
*
* @param key
* @return true if the key exists on the OrcidPropsEntity table
* @throws NonUniqueResultException
* if there are more than one row with the same key name
* */
@Override
public boolean exists(String key) throws NonUniqueResultException {
Assert.hasText(key, "Cannot look for empty keys");
Query query = entityManager.createQuery("FROM OrcidPropsEntity WHERE key=:key");
query.setParameter("key", key);
try {
query.getSingleResult();
} catch (NoResultException nre) {
return false;
} catch (NonUniqueResultException nure) {
throw nure;
}
return true;
}
use of javax.persistence.NoResultException in project ORCID-Source by ORCID.
the class InternalSSODaoImpl method getRecordLastModified.
@Override
public Date getRecordLastModified(String orcid, String token, Date maxAge) {
TypedQuery<Date> query = entityManager.createQuery("SELECT lastModified FROM InternalSSOEntity WHERE orcid = :orcid AND token = :token AND last_modified >= :maxAge", Date.class);
query.setParameter("orcid", orcid);
query.setParameter("token", token);
query.setParameter("maxAge", maxAge);
try {
Date result = query.getSingleResult();
return result;
} catch (NoResultException nre) {
}
return null;
}
Aggregations