Return-Path: X-Original-To: apmail-chemistry-dev-archive@www.apache.org Delivered-To: apmail-chemistry-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5EC1811B69 for ; Fri, 25 Jul 2014 13:45:38 +0000 (UTC) Received: (qmail 74317 invoked by uid 500); 25 Jul 2014 13:45:38 -0000 Delivered-To: apmail-chemistry-dev-archive@chemistry.apache.org Received: (qmail 74282 invoked by uid 500); 25 Jul 2014 13:45:38 -0000 Mailing-List: contact dev-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list dev@chemistry.apache.org Received: (qmail 74271 invoked by uid 99); 25 Jul 2014 13:45:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jul 2014 13:45:37 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of j.huebel@sap.com designates 155.56.66.98 as permitted sender) Received: from [155.56.66.98] (HELO smtpgw.sap-ag.de) (155.56.66.98) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jul 2014 13:45:36 +0000 From: "Huebel, Jens" To: "dev@chemistry.apache.org" , "Robert.Williams3@wellsfargo.com" Subject: Re: OpenCMIS SQL Parsing Question Thread-Topic: OpenCMIS SQL Parsing Question Thread-Index: Ac+oDTP7dmdZoaWhRDuh/CFfAjU4BwAAXOCA Date: Fri, 25 Jul 2014 13:45:10 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.4.1.140326 x-originating-ip: [10.21.40.110] Content-Type: text/plain; charset="us-ascii" Content-ID: <2A122D93B5CEC142A2D1066AE0ACC43B@exchange.sap.corp> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org 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" 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 =3D '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. > > Query String has illegal tokens after end of >statement: [@15,63:63=3D'<EOF>',<-1>,1:63] > > xmlns:ns2=3D"http://docs.oasis-open.org/ns/cmis/core/200908/" >xmlns=3D"http://docs.oasis-open.org/ns/cmis/messaging/200908/" >xmlns:cmisFault=3D"http://docs.oasis-open.org/ns/cmis/messaging/200908/"> > invalidArgument > 0 > Query String has illegal tokens after end of >statement: [@15,63:63=3D'<EOF>',<-1>,1:63] > xmlns=3D"http://chemistry.apache.org/opencmis/exception" >xmlns:stacktrace=3D"http://chemistry.apache.org/opencmis/exception">org.ap= ac >he.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: >Query String has illegal tokens after end of statement: >[@15,63:63=3D'<EOF>',<-1>,1:63] > at=20 >org.apache.chemistry.opencmis.server.support.query.QueryUtil.getWalker(Que >ryUtil.java:83) > at=20 >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 =3D new ANTLRStringStream(statement); > TokenSource lexer =3D new CmisQlStrictLexer(input); > TokenStream tokens =3D new CommonTokenStream(lexer); > CmisQlStrictParser parser =3D new CmisQlStrictParser(tokens); > CommonTree parserTree; // the ANTLR tree after parsing phase > > query_return parsedStatement =3D parser.query(); > if (parser.hasErrors()) { > throw new >CmisInvalidArgumentException(parser.getErrorMessages()); > } else if ( tokens.index()!=3Dtokens.size() ) { > throw new CmisInvalidArgumentException("Query String has >illegal tokens after end of statement: " + tokens.get(tokens.index())); > } > > parserTree =3D (CommonTree) parsedStatement.getTree(); > > CommonTreeNodeStream nodes =3D new CommonTreeNodeStream(parserTree= ); > nodes.setTokenStream(tokens); > CmisQueryWalker walker =3D 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! > >