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;
}
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;
}
Aggregations