Example usage for javax.ejb AsyncResult AsyncResult

List of usage examples for javax.ejb AsyncResult AsyncResult

Introduction

In this page you can find the example usage for javax.ejb AsyncResult AsyncResult.

Prototype

public AsyncResult(V result) 

Source Link

Document

Creates a AsyncResult instance to wrap the result of an asynchronous method call

Usage

From source file:com.inqool.dcap.office.indexer.indexer.SolrBulkIndexer.java

public Future<UpdateResponse> remove(final String id) {
    logger.debug("Received request for removal of: {}", id);
    try {/*from   www  . j a v a2s .  c om*/
        SolrServer server = new HttpSolrServer(SOLR_MAIN_ENDPOINT);
        //first delete children
        //not needed, if _root_ is indexed, children are deleted with parent?
        //or now it doesn't work again? weird
        final UpdateResponse resp0 = server.deleteByQuery("_root_:\"" + id + "\"");
        if (resp0.getStatus() == 0) {
            logger.debug("Remove request was successful for children of: {}", id);
        } else {
            logger.error("Remove request has error, code: {} for pid: {}", resp0.getStatus(), id);
            return new AsyncResult<>(resp0);
        }

        final UpdateResponse resp1 = server.deleteById(id);
        if (resp1.getStatus() == 0) {
            logger.debug("Remove request was successful for: {}", id);
        } else {
            logger.error("Remove request has error, code: {} for pid: {}", resp1.getStatus(), id);
        }

        //Also delete suggester data belonging to the document root
        SolrServer suggesterServer = new HttpSolrServer(SOLR_SUGGESTER_ENDPOINT);
        final UpdateResponse resp2 = suggesterServer.deleteByQuery("belongsTo:\"" + id + "\"");
        if (resp2.getStatus() == 0) {
            logger.debug("Remove request was successful for suggester data of: {}", id);
        } else {
            logger.error("Remove request for suggester data has error, code: {} for pid: {}", resp2.getStatus(),
                    id);
        }
        return new AsyncResult<>(resp1);
    } catch (final SolrServerException | IOException e) {
        logger.error("Delete Exception: {}", e);
        throw new RuntimeException(e);
    }
}