Search in sources :

Example 1 with MessageListResult

use of org.eclipse.kapua.service.datastore.model.MessageListResult in project kapua by eclipse.

the class MessageStoreServiceImpl method find.

@Override
public Message find(KapuaId scopeId, StorableId id, MessageFetchStyle fetchStyle) throws KapuaException {
    // 
    // Argument Validation
    ArgumentValidator.notNull(scopeId, "scopeId");
    ArgumentValidator.notNull(id, "id");
    ArgumentValidator.notNull(fetchStyle, "fetchStyle");
    // 
    // Check Access
    this.checkDataAccess(scopeId, Actions.read);
    AccountInfo accountInfo = getAccountServicePlan(scopeId);
    String scopeName = accountInfo.getAccount().getName();
    try {
        String everyIndex = EsUtils.getAnyIndexName(scopeName);
        MessageListResult result = null;
        result = EsMessageDAO.connection(EsClient.getcurrent()).instance(everyIndex, EsSchema.MESSAGE_TYPE_NAME).query(null);
        if (true)
            throw KapuaException.internalError("Method not implemented.");
        return null;
    } catch (Exception exc) {
        // CassandraUtils.handleException(e);
        throw KapuaException.internalError(exc);
    }
}
Also used : MessageListResult(org.eclipse.kapua.service.datastore.model.MessageListResult) KapuaInvalidTopicException(org.eclipse.kapua.service.datastore.internal.elasticsearch.KapuaInvalidTopicException) ParseException(java.text.ParseException) EsDatastoreException(org.eclipse.kapua.service.datastore.internal.elasticsearch.EsDatastoreException) DocumentAlreadyExistsException(org.elasticsearch.index.engine.DocumentAlreadyExistsException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) KapuaException(org.eclipse.kapua.KapuaException)

Example 2 with MessageListResult

use of org.eclipse.kapua.service.datastore.model.MessageListResult in project kapua by eclipse.

the class MessageStoreServiceImpl method query.

@Override
public MessageListResult query(KapuaId scopeId, MessageQuery query) throws KapuaException {
    // 
    // Argument Validation
    ArgumentValidator.notNull(scopeId, "scopeId");
    ArgumentValidator.notNull(query, "query");
    // 
    // Check Access
    this.checkDataAccess(scopeId, Actions.read);
    // 
    // Do the find
    AccountInfo accountInfo = getAccountServicePlan(scopeId);
    String scopeName = accountInfo.getAccount().getName();
    LocalServicePlan accountServicePlan = accountInfo.getServicePlan();
    long ttl = accountServicePlan.getDataTimeToLive() * DAY_MILLIS;
    if (!accountServicePlan.getDataStorageEnabled() || ttl == LocalServicePlan.DISABLED) {
        logger.debug("Storage not enabled for account {}, returning empty result", scopeName);
        return new MessageListResultImpl();
    }
    try {
        String everyIndex = EsUtils.getAnyIndexName(scopeName);
        MessageListResult result = null;
        result = EsMessageDAO.connection(EsClient.getcurrent()).instance(everyIndex, EsSchema.MESSAGE_TYPE_NAME).query(query);
        return result;
    } catch (Exception exc) {
        // CassandraUtils.handleException(e);
        throw KapuaException.internalError(exc);
    }
}
Also used : MessageListResultImpl(org.eclipse.kapua.service.datastore.internal.model.MessageListResultImpl) LocalServicePlan(org.eclipse.kapua.service.datastore.internal.elasticsearch.LocalServicePlan) MessageListResult(org.eclipse.kapua.service.datastore.model.MessageListResult) KapuaInvalidTopicException(org.eclipse.kapua.service.datastore.internal.elasticsearch.KapuaInvalidTopicException) ParseException(java.text.ParseException) EsDatastoreException(org.eclipse.kapua.service.datastore.internal.elasticsearch.EsDatastoreException) DocumentAlreadyExistsException(org.elasticsearch.index.engine.DocumentAlreadyExistsException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) KapuaException(org.eclipse.kapua.KapuaException)

Aggregations

IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2 ParseException (java.text.ParseException)2 KapuaException (org.eclipse.kapua.KapuaException)2 EsDatastoreException (org.eclipse.kapua.service.datastore.internal.elasticsearch.EsDatastoreException)2 KapuaInvalidTopicException (org.eclipse.kapua.service.datastore.internal.elasticsearch.KapuaInvalidTopicException)2 MessageListResult (org.eclipse.kapua.service.datastore.model.MessageListResult)2 DocumentAlreadyExistsException (org.elasticsearch.index.engine.DocumentAlreadyExistsException)2 LocalServicePlan (org.eclipse.kapua.service.datastore.internal.elasticsearch.LocalServicePlan)1 MessageListResultImpl (org.eclipse.kapua.service.datastore.internal.model.MessageListResultImpl)1