Search in sources :

Example 1 with RequestScope

use of com.yahoo.elide.core.security.RequestScope in project elide by yahoo.

the class ElideAsyncConfiguration method getTableExportHook.

// TODO Remove this method when ElideSettings has all the settings.
// Then the check can be done in TableExportHook.
// Trying to avoid adding too many individual properties to ElideSettings for now.
// https://github.com/yahoo/elide/issues/1803
private TableExportHook getTableExportHook(AsyncExecutorService asyncExecutorService, ElideConfigProperties settings, Map<ResultType, TableExportFormatter> supportedFormatters, ResultStorageEngine resultStorageEngine) {
    boolean exportEnabled = ElideAutoConfiguration.isExportEnabled(settings.getAsync());
    TableExportHook tableExportHook = null;
    if (exportEnabled) {
        tableExportHook = new TableExportHook(asyncExecutorService, settings.getAsync().getMaxAsyncAfterSeconds(), supportedFormatters, resultStorageEngine);
    } else {
        tableExportHook = new TableExportHook(asyncExecutorService, settings.getAsync().getMaxAsyncAfterSeconds(), supportedFormatters, resultStorageEngine) {

            @Override
            public void validateOptions(AsyncAPI export, RequestScope requestScope) {
                throw new InvalidOperationException("TableExport is not supported.");
            }
        };
    }
    return tableExportHook;
}
Also used : AsyncAPI(com.yahoo.elide.async.models.AsyncAPI) TableExportHook(com.yahoo.elide.async.hooks.TableExportHook) InvalidOperationException(com.yahoo.elide.core.exceptions.InvalidOperationException) RequestScope(com.yahoo.elide.core.security.RequestScope)

Example 2 with RequestScope

use of com.yahoo.elide.core.security.RequestScope in project elide by yahoo.

the class TableExportHook method getOperation.

@Override
public Callable<AsyncAPIResult> getOperation(AsyncAPI export, RequestScope requestScope) {
    Callable<AsyncAPIResult> operation = null;
    TableExport exportObj = (TableExport) export;
    ResultType resultType = exportObj.getResultType();
    QueryType queryType = exportObj.getQueryType();
    com.yahoo.elide.core.RequestScope scope = (com.yahoo.elide.core.RequestScope) requestScope;
    TableExportFormatter formatter = supportedFormatters.get(resultType);
    if (formatter == null) {
        throw new InvalidOperationException("Formatter unavailable for " + resultType);
    }
    if (queryType.equals(QueryType.GRAPHQL_V1_0)) {
        operation = new GraphQLTableExportOperation(formatter, getAsyncExecutorService(), export, scope, engine);
    } else if (queryType.equals(QueryType.JSONAPI_V1_0)) {
        operation = new JSONAPITableExportOperation(formatter, getAsyncExecutorService(), export, scope, engine);
    } else {
        throw new InvalidOperationException(queryType + "is not supported");
    }
    return operation;
}
Also used : JSONAPITableExportOperation(com.yahoo.elide.async.operation.JSONAPITableExportOperation) ResultType(com.yahoo.elide.async.models.ResultType) RequestScope(com.yahoo.elide.core.security.RequestScope) TableExport(com.yahoo.elide.async.models.TableExport) InvalidOperationException(com.yahoo.elide.core.exceptions.InvalidOperationException) GraphQLTableExportOperation(com.yahoo.elide.async.operation.GraphQLTableExportOperation) AsyncAPIResult(com.yahoo.elide.async.models.AsyncAPIResult) QueryType(com.yahoo.elide.async.models.QueryType) TableExportFormatter(com.yahoo.elide.async.export.formatter.TableExportFormatter)

Aggregations

InvalidOperationException (com.yahoo.elide.core.exceptions.InvalidOperationException)2 RequestScope (com.yahoo.elide.core.security.RequestScope)2 TableExportFormatter (com.yahoo.elide.async.export.formatter.TableExportFormatter)1 TableExportHook (com.yahoo.elide.async.hooks.TableExportHook)1 AsyncAPI (com.yahoo.elide.async.models.AsyncAPI)1 AsyncAPIResult (com.yahoo.elide.async.models.AsyncAPIResult)1 QueryType (com.yahoo.elide.async.models.QueryType)1 ResultType (com.yahoo.elide.async.models.ResultType)1 TableExport (com.yahoo.elide.async.models.TableExport)1 GraphQLTableExportOperation (com.yahoo.elide.async.operation.GraphQLTableExportOperation)1 JSONAPITableExportOperation (com.yahoo.elide.async.operation.JSONAPITableExportOperation)1