chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject OpenCMIS SQL Parsing Question
Date Fri, 25 Jul 2014 13:34:54 GMT

I am new to CMIS and I am presently looking at handling query functionality in our CMIS Server,.
 To this end, I am attempting to implement the code specified  in section 1.7 entitled "Parsing
a CMIS Query" in chapter 14 of the text CMIS and Apache Chemistry in Action.  While this example
code seems very straight forward, I am getting the following error when invoking it for the
CMIS SQL statement:  Select * from cmis:document where cmis:name = 'My_Document-0-0'.  I have
tried variations such as ending the SQL statement with a semicolon and others, but the result
has been the same.

         <faultstring>Query String has illegal tokens after end of statement: [@15,63:63='&lt;EOF>',&lt;-1>,1:63]</faultstring>
            <cmisFault:cmisFault xmlns:ns2=""
xmlns="" xmlns:cmisFault="">
               <message>Query String has illegal tokens after end of statement: [@15,63:63='&lt;EOF>',&lt;-1>,1:63]</message>
               <stacktrace:stacktrace xmlns=""
Query String has illegal tokens after end of statement: [@15,63:63='&lt;EOF>',&lt;-1>,1:63]

Based on debugging that I've performed, the CMIS SQL statement looks like it is getting into
the code unaltered, but it goes off the rails somewhere.

The following is the QueryUtil::getWalker() method that is failing, specifically the highlighted

    public static CmisQueryWalker getWalker(String statement) throws RecognitionException
        CharStream input = new ANTLRStringStream(statement);
        TokenSource lexer = new CmisQlStrictLexer(input);
        TokenStream tokens = new CommonTokenStream(lexer);
        CmisQlStrictParser parser = new CmisQlStrictParser(tokens);
        CommonTree parserTree; // the ANTLR tree after parsing phase

        query_return parsedStatement = parser.query();
        if (parser.hasErrors()) {
            throw new CmisInvalidArgumentException(parser.getErrorMessages());
        } else if ( tokens.index()!=tokens.size() ) {
            throw new  CmisInvalidArgumentException("Query String has illegal tokens after
end of statement: " + tokens.get(tokens.index()));

        parserTree = (CommonTree) parsedStatement.getTree();

        CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
        CmisQueryWalker walker = new CmisQueryWalker(nodes);
        return walker;

I did notice that the QueryUtil class is deprecated.  Further, as a result of digging around,
I have discovered an OpenCMIS Query Parser Example directory.  The parsing done in these files
uses the QueryUtilStrict class and seems to be done a little differently.  Should I use this
example code for CMIS SQL parsing instead of the example in the text?

Thanks in advance for any and all assistance!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message