chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Huebel, Jens" <j.hue...@sap.com>
Subject Re: OpenCMIS SQL Parsing Question
Date Fri, 25 Jul 2014 13:45:10 GMT
Yes, please try to use the QueryUtilStrict class. We did at some point a
certain refactoring for those cases where server implementations want to
to enhancements to the grammar. The sample is the most up-to-date code we
have. This should be a good starting point.

The error message indicates that your query string has some characters at
the end after the query string ends.

Jens


On 25/07/14 15:34, "Robert.Williams3@wellsfargo.com"
<Robert.Williams3@wellsfargo.com> wrote:

>Hello,
>
>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>
>         <detail>
>            <cmisFault:cmisFault
>xmlns:ns2="http://docs.oasis-open.org/ns/cmis/core/200908/"
>xmlns="http://docs.oasis-open.org/ns/cmis/messaging/200908/"
>xmlns:cmisFault="http://docs.oasis-open.org/ns/cmis/messaging/200908/">
>               <type>invalidArgument</type>
>               <code>0</code>
>               <message>Query String has illegal tokens after end of
>statement: [@15,63:63='&lt;EOF>',&lt;-1>,1:63]</message>
>               <stacktrace:stacktrace
>xmlns="http://chemistry.apache.org/opencmis/exception"
>xmlns:stacktrace="http://chemistry.apache.org/opencmis/exception">org.apac
>he.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException:
>Query String has illegal tokens after end of statement:
>[@15,63:63='&lt;EOF>',&lt;-1>,1:63]
>        at 
>org.apache.chemistry.opencmis.server.support.query.QueryUtil.getWalker(Que
>ryUtil.java:83)
>        at 
>org.apache.chemistry.opencmis.server.support.query.QueryUtil.traverseState
>ment(QueryUtil.java:112)
>
>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 code:
>
>    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);
>        nodes.setTokenStream(tokens);
>        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!
>
>


Mime
View raw message