Search in sources :

Example 16 with NonTransientDataAccessResourceException

use of org.springframework.dao.NonTransientDataAccessResourceException in project ORCID-Source by ORCID.

the class OrcidSearchManagerImpl method findPublicProfileById.

@Override
public OrcidMessage findPublicProfileById(String orcid) {
    OrcidMessage om = null;
    try {
        if (cachingSource.equals(DB)) {
            OrcidProfile orcidProfile = orcidProfileCacheManager.retrievePublic(orcid);
            orcidProfile.setOrcidInternal(null);
            om = new OrcidMessage(orcidProfile);
        } else {
            try (Reader reader = solrDao.findByOrcidAsReader(orcid)) {
                if (reader != null) {
                    BufferedReader br = new BufferedReader(reader);
                    om = OrcidMessage.unmarshall(br);
                }
            }
        }
    } catch (NonTransientDataAccessResourceException e) {
        throw new OrcidSearchException("Error searching by id: " + orcid, e);
    } catch (IOException e) {
        throw new OrcidSearchException("Error closing stream for id: " + orcid, e);
    }
    if (om == null)
        throw new OrcidSearchException("Result is null");
    return om;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) OrcidSearchException(org.orcid.core.exception.OrcidSearchException) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) BufferedReader(java.io.BufferedReader) Reader(java.io.Reader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Example 17 with NonTransientDataAccessResourceException

use of org.springframework.dao.NonTransientDataAccessResourceException in project hedera-mirror-node by hashgraph.

the class ProtoUtilTest method toStatusRuntimeException.

@Test
void toStatusRuntimeException() {
    var entityId = EntityId.of(1L, EntityType.ACCOUNT);
    var message = "boom";
    assertException(Exceptions.failWithOverflow(message), Status.DEADLINE_EXCEEDED, OVERFLOW_ERROR);
    assertException(new ConstraintViolationException(message, null), Status.INVALID_ARGUMENT, message);
    assertException(new IllegalArgumentException(message), Status.INVALID_ARGUMENT, message);
    assertException(new InvalidEntityException(message), Status.INVALID_ARGUMENT, message);
    assertException(new EntityNotFoundException(entityId), Status.NOT_FOUND, "Account 0.0.1 does not exist");
    assertException(new NonTransientDataAccessResourceException(message), Status.UNAVAILABLE, DB_ERROR);
    assertException(new QueryTimeoutException(message), Status.RESOURCE_EXHAUSTED, DB_ERROR);
    assertException(new TimeoutException(message), Status.RESOURCE_EXHAUSTED, DB_ERROR);
    assertException(new RuntimeException(message), Status.UNKNOWN, UNKNOWN_ERROR);
}
Also used : QueryTimeoutException(org.springframework.dao.QueryTimeoutException) NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) StatusRuntimeException(io.grpc.StatusRuntimeException) ConstraintViolationException(javax.validation.ConstraintViolationException) EntityNotFoundException(com.hedera.mirror.grpc.exception.EntityNotFoundException) InvalidEntityException(com.hedera.mirror.common.exception.InvalidEntityException) QueryTimeoutException(org.springframework.dao.QueryTimeoutException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with NonTransientDataAccessResourceException

use of org.springframework.dao.NonTransientDataAccessResourceException in project dcache by dCache.

the class JdbcFs method inTransaction.

private <T> T inTransaction(FallibleTransactionCallback<T> callback) throws ChimeraFsException {
    TransactionStatus status = _tx.getTransaction(_txDefinition);
    T result;
    try {
        result = callback.doInTransaction(status);
        _tx.commit(status);
    } catch (ChimeraFsException e) {
        rollbackOnException(status, e);
        throw e;
    } catch (NonTransientDataAccessResourceException e) {
        rollbackOnException(status, e);
        throw new BackEndErrorChimeraFsException(e.getMessage(), e);
    } catch (DataAccessException e) {
        rollbackOnException(status, e);
        throw new ChimeraFsException(e.getMessage(), e);
    } catch (Exception e) {
        rollbackOnException(status, e);
        throw e;
    }
    return result;
}
Also used : NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) STAT(org.dcache.chimera.FileSystemProvider.StatCacheOption.STAT) NO_STAT(org.dcache.chimera.FileSystemProvider.StatCacheOption.NO_STAT) TransactionStatus(org.springframework.transaction.TransactionStatus) DataAccessException(org.springframework.dao.DataAccessException) NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) TransactionSystemException(org.springframework.transaction.TransactionSystemException) DataAccessException(org.springframework.dao.DataAccessException) SQLException(java.sql.SQLException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) DuplicateKeyException(org.springframework.dao.DuplicateKeyException) TransactionException(org.springframework.transaction.TransactionException)

Aggregations

NonTransientDataAccessResourceException (org.springframework.dao.NonTransientDataAccessResourceException)18 SolrServerException (org.apache.solr.client.solrj.SolrServerException)13 IOException (java.io.IOException)8 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)8 SolrQuery (org.apache.solr.client.solrj.SolrQuery)7 SolrDocument (org.apache.solr.common.SolrDocument)4 OrcidSolrDocument (org.orcid.utils.solr.entities.OrcidSolrDocument)4 BufferedReader (java.io.BufferedReader)2 Reader (java.io.Reader)2 Date (java.util.Date)2 OrcidSearchException (org.orcid.core.exception.OrcidSearchException)2 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)2 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)2 OrcidSolrResult (org.orcid.utils.solr.entities.OrcidSolrResult)2 DataAccessException (org.springframework.dao.DataAccessException)2 InvalidEntityException (com.hedera.mirror.common.exception.InvalidEntityException)1 EntityNotFoundException (com.hedera.mirror.grpc.exception.EntityNotFoundException)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 File (java.io.File)1 InputStream (java.io.InputStream)1