Example usage for org.springframework.dao DataAccessResourceFailureException DataAccessResourceFailureException

List of usage examples for org.springframework.dao DataAccessResourceFailureException DataAccessResourceFailureException

Introduction

In this page you can find the example usage for org.springframework.dao DataAccessResourceFailureException DataAccessResourceFailureException.

Prototype

public DataAccessResourceFailureException(String msg, @Nullable Throwable cause) 

Source Link

Document

Constructor for DataAccessResourceFailureException.

Usage

From source file:org.dkpro.lab.storage.filesystem.FileSystemStorageService.java

@Override
public void delete(String aContextId) {
    try {/*from w ww.j  av  a  2  s.  c  o m*/
        FileUtils.deleteDirectory(getContextFolder(aContextId, false));
    } catch (IOException e) {
        throw new DataAccessResourceFailureException(e.getMessage(), e);
    }
}

From source file:com.frank.search.solr.core.SolrExceptionTranslator.java

@Override
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
    if (ex.getCause() instanceof SolrServerException) {
        SolrServerException solrServerException = (SolrServerException) ex.getCause();
        if (solrServerException.getCause() instanceof SolrException) {
            SolrException solrException = (SolrException) solrServerException.getCause();
            // solr 4.x moved ParseExecption from org.apache.lucene.queryParser to org.apache.lucene.queryparser.classic
            // therefore compare ShortClassName instead of using instanceof expression
            if (solrException.getCause() != null && ClassUtils.getShortName(solrException.getCause().getClass())
                    .equalsIgnoreCase("ParseException")) {
                return new InvalidDataAccessApiUsageException((solrException.getCause()).getMessage(),
                        solrException.getCause());
            } else {
                ErrorCode errorCode = ErrorCode.getErrorCode(solrException.code());
                switch (errorCode) {
                case NOT_FOUND:
                case SERVICE_UNAVAILABLE:
                case SERVER_ERROR:
                    return new DataAccessResourceFailureException(solrException.getMessage(), solrException);
                case FORBIDDEN:
                case UNAUTHORIZED:
                    return new PermissionDeniedDataAccessException(solrException.getMessage(), solrException);
                case BAD_REQUEST:
                    return new InvalidDataAccessApiUsageException(solrException.getMessage(), solrException);
                case UNKNOWN:
                    return new UncategorizedSolrException(solrException.getMessage(), solrException);
                default:
                    break;
                }//from   w  ww.  j  a  v  a  2  s  .c o m
            }
        } else if (solrServerException.getCause() instanceof ConnectException) {
            return new DataAccessResourceFailureException(solrServerException.getCause().getMessage(),
                    solrServerException.getCause());
        }
    }
    return null;
}

From source file:org.dkpro.lab.storage.filesystem.FileSystemStorageService.java

@Override
public void delete(String aContextId, String aKey) {
    try {/*  www.j a  v  a  2  s.  c o  m*/
        FileUtils.deleteDirectory(new File(getContextFolder(aContextId, false), aKey));
    } catch (IOException e) {
        throw new DataAccessResourceFailureException(e.getMessage(), e);
    }
}

From source file:org.grails.datastore.mapping.jcr.JcrSession.java

@Override
public void disconnect() {
    //        interceptor.afterCompletion(null, null, null, null);
    try {//from   w  w  w  . j  av a 2s  .co m
        ((TransientRepository) jcrSessionFactory.getRepository()).shutdown();
        super.disconnect();
    } catch (Exception e) {
        throw new DataAccessResourceFailureException("Failed to disconnect JCR Repository: " + e.getMessage(),
                e);
    } finally {
        super.disconnect();
    }
}

From source file:org.spring.data.gemfire.app.dao.GemfireRegionCustomerDao.java

public Customer save(Customer customer) {
    try {//w  w  w  .  j a  va  2  s .  c  o m
        if (customer.isNew()) {
            customer.setId(ID_SEQUENCE.incrementAndGet());
            customersRegion().putIfAbsent(customer.getId(), customer);
        } else {
            customersRegion().put(customer.getId(), customer);
        }

        return customer;
    } catch (CacheWriterException e) {
        throw new DataAccessResourceFailureException("write-through failed", e);
    } catch (LeaseExpiredException e) {
        throw new PessimisticLockingFailureException("global lock lease expired", e);
    } catch (LowMemoryException e) {
        throw new DataAccessResourceFailureException("low memory", e);
    } catch (PartitionedRegionStorageException e) {
        throw new DataAccessResourceFailureException("PR op failure", e);
    } catch (TimeoutException e) {
        throw new DeadlockLoserDataAccessException("global lock acquisition timeout", e);
    } catch (GemFireException e) {
        throw GemfireCacheUtils.convertGemfireAccessException(e);
    }
}

From source file:com.jpeterson.littles3.dao.je.JeBucketDao.java

/**
 * This method retrieves the <code>Bucket</code> representation of a
 * bucket from the underlying JE database via the bucket's name.
 * //from  ww w. j  a va  2 s  .c o m
 * @param bucket
 *            The bucket name.
 * @throws DataRetrievalFailureException
 *             Could not find the <code>Bucket</code> for the provided
 *             <code>bucket</code> name.
 * @throws DataAccessResourceFailureException
 *             General failure retrieving the bucket from the JE database.
 * @throws DataAccessException
 *             General failure retrieving the bucket.
 */
public Bucket loadBucket(String bucket) throws DataAccessException {
    DatabaseEntry theKey;
    DatabaseEntry theData;

    // Environment myDbEnvironment = null;
    Database database = null;

    try {
        theKey = new DatabaseEntry(bucket.getBytes("UTF-8"));
        theData = new DatabaseEntry();

        database = jeCentral.getDatabase(JeCentral.BUCKET_DB_NAME);

        if (database.get(null, theKey, theData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
            return (Bucket) bucketBinding.entryToObject(theData);
        } else {
            throw new DataRetrievalFailureException("Could not find Bucket: " + bucket);
        }
    } catch (DatabaseException e) {
        throw new DataAccessResourceFailureException("Unable to load a database record", e);
    } catch (UnsupportedEncodingException e) {
        // should not happen
        e.printStackTrace();
        throw new DataAccessResourceFailureException("Unexpected encoding error", e);
    }
}

From source file:org.grails.datastore.mapping.transactions.DatastoreTransactionManager.java

@Override
protected Object doGetTransaction() throws TransactionException {
    TransactionObject txObject = new TransactionObject();

    SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(getDatastore());
    if (sessionHolder != null) {
        if (logger.isDebugEnabled()) {
            logger.debug("Found thread-bound Session [" + sessionHolder.getSession()
                    + "] for Datastore transaction");
        }//from   w w w.j  a v a 2  s  .com
        txObject.setSessionHolder(sessionHolder);
    } else if (datastoreManagedSession) {
        try {
            Session session = getDatastore().getCurrentSession();
            if (logger.isDebugEnabled()) {
                logger.debug(
                        "Found Datastore-managed Session [" + session + "] for Spring-managed transaction");
            }
            txObject.setExistingSession(session);
        } catch (ConnectionNotFoundException ex) {
            throw new DataAccessResourceFailureException(
                    "Could not obtain Datastore-managed Session for Spring-managed transaction", ex);
        }
    } else {
        Session session = getDatastore().connect();
        txObject.setSession(session);
    }

    return txObject;
}

From source file:org.grails.datastore.mapping.jcr.JcrSession.java

@Override
public boolean isConnected() {
    try {/*w w w  .jav  a 2 s .c  om*/
        return jcrSessionFactory.getSession().isLive();
    } catch (RepositoryException e) {
        throw new DataAccessResourceFailureException("Repository Errors: " + e.getMessage(), e);
    }
}

From source file:org.grails.datastore.mapping.jcr.JcrSession.java

public Session getNativeInterface() {
    try {/*www. j  av  a  2  s . com*/
        return jcrSessionFactory.getSession();
    } catch (RepositoryException e) {
        throw new DataAccessResourceFailureException("Session not found: " + e.getMessage(), e);
    }
}

From source file:de.tudarmstadt.ukp.csniper.webapp.search.cqp.CqpEngine.java

public String getEncoding(String aCollectionId) {
    try {//from w  ww .j a v  a2  s .  co m
        List<String> lines = FileUtils.readLines(new File(getRegistryPath(), aCollectionId.toLowerCase()),
                "UTF-8");
        for (String line : lines) {
            line = line.toLowerCase();
            if (line.startsWith("##:: charset")) {
                if (line.contains("iso-8859-1") || line.contains("latin1")) {
                    return "ISO-8859-1";
                }
                break;
            }
        }
        return "UTF-8";
    } catch (IOException e) {
        throw new DataAccessResourceFailureException("Unable to read registry file", e);
    }
}