@ GET @ Path ( "parse/nodes" ) @ Produces ( "application/xml" ) public Response parseNodes ( @ QueryParam ( "q" ) String query , @ DefaultValue ( "" ) @ QueryParam ( "corpora" ) String rawCorpusNames ) { Subject user = SecurityUtils . getSubject ( ) ; List < String > corpusNames = splitCorpusNamesFromRaw ( rawCorpusNames ) ; for ( String c : corpusNames ) { user . checkPermission ( "query:parse:" + c ) ; } Collections . sort ( corpusNames ) ; List < Long > corpusIDs = queryDao . mapCorpusNamesToIds ( corpusNames ) ; QueryData data = queryDao . parseAQL ( query , corpusIDs ) ; List < QueryNode > nodes = new LinkedList <> ( ) ; int i = 0 ; for ( List < QueryNode > alternative : data . getAlternatives ( ) ) { for ( QueryNode n : alternative ) { n . setAlternativeNumber ( i ) ; nodes . add ( n ) ; } i ++ ; } return Response . ok ( new GenericEntity < List < QueryNode > > ( nodes ) { } ) . build ( ) ; }
Return the list of the query nodes if this is a valid query or throw exception when invalid