@ GET @ Path ( "corpora/example-queries/" ) @ Produces ( MediaType . APPLICATION_XML ) public List < ExampleQuery > getExampleQueries ( @ QueryParam ( "corpora" ) String rawCorpusNames ) throws WebApplicationException { Subject user = SecurityUtils . getSubject ( ) ; try { String [ ] corpusNames ; if ( rawCorpusNames != null ) { corpusNames = rawCorpusNames . split ( "," ) ; } else { List < AnnisCorpus > allCorpora = queryDao . listCorpora ( ) ; corpusNames = new String [ allCorpora . size ( ) ] ; for ( int i = 0 ; i < corpusNames . length ; i ++ ) { corpusNames [ i ] = allCorpora . get ( i ) . getName ( ) ; } } List < String > allowedCorpora = new ArrayList <> ( ) ; // filter by which corpora the user is allowed to access for ( String c : corpusNames ) { if ( user . isPermitted ( "query:*:" + c ) ) { allowedCorpora . add ( c ) ; } } List < Long > corpusIDs = queryDao . mapCorpusNamesToIds ( allowedCorpora ) ; return queryDao . getExampleQueries ( corpusIDs ) ; } catch ( Exception ex ) { log . error ( "Problem accessing example queries" , ex ) ; throw new WebApplicationException ( ex , 500 ) ; } }
Fetches the example queries for a specific corpus .