class ApplicationsResource extends RealmAwareResource {

    @Override
    public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request,
            QueryResourceHandler handler) {

        final Subject subject = getContextSubject(context);
        if (subject == null) {
            debug.error("ApplicationsResource :: UPDATE : Unknown Subject");
            return new BadRequestException().asPromise();
        }

        final String realm = getRealm(context);
        QueryFilter<JsonPointer> queryFilter = request.getQueryFilter();
        if (queryFilter == null) {
            // Return everything
            queryFilter = QueryFilter.alwaysTrue();
        }
        QueryFilter<String> stringQueryFilter = queryFilter.accept(new QueryByStringFilterConverter(), null);
        try {
            Set<Application> applications = appService(subject, realm).search(stringQueryFilter);
            List<ResourceResponse> results = new ArrayList<>();
            for (Application application : applications) {
                results.add(newResourceResponse(application.getName(), null, applicationToJson(application)));
            }
            QueryResponsePresentation.enableDeprecatedRemainingQueryResponse(request);
            return QueryResponsePresentation.perform(handler, request, results);
        } catch (EntitlementException e) {
            debug.error("ApplicationsResource :: QUERY by {}: Failed to query resource.",
                    getPrincipalNameFromSubject(subject), e);
            return exceptionMappingHandler.handleError(context, request, e).asPromise();
        }
    }

    @Inject public  ApplicationsResource(@Named("frRest") Debug debug, ApplicationServiceFactory applicationServiceFactory,
            ApplicationTypeManagerWrapper appTypeManagerWrapper,
            ExceptionMappingHandler<EntitlementException, ResourceException> exceptionMappingHandler);

}