Changeset 7616 for RevitalizationWS


Ignore:
Timestamp:
19/10/10 08:07:16 (9 years ago)
Author:
mnagni
Message:

Fixed a bug in the TermTarget? parser (incorrectly parse text with a double quote at the end or the beginning or having a single AND/OR as text)
Promoted pom version to 1.1.1

Location:
RevitalizationWS/common/core/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • RevitalizationWS/common/core/trunk/pom.xml

    r7543 r7616  
    55        <groupId>ndg.services</groupId> 
    66        <artifactId>common</artifactId> 
    7         <version>1.1.0</version> 
     7        <version>1.1.1</version> 
    88 
    99        <name>NDG commons</name> 
  • RevitalizationWS/common/core/trunk/src/main/java/ndg/common/TermParser.java

    r7269 r7616  
    88 
    99/** 
    10  *      BSD Licence 
    11  *      Copyright (c) 2009, Science & Technology Facilities Council (STFC) 
    12  *      All rights reserved.     
    13  *  See the LICENSE file in the source distribution of this software for 
    14  *      the full license text. 
     10 * BSD Licence 
     11 * Copyright (c) 2009, Science & Technology Facilities Council (STFC) All rights reserved. 
     12 * Redistribution and use in source and binary forms, with or without 
     13 * modification, are permitted provided that the following conditions are 
     14 * met: 
    1515 * 
    16  * Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council). 
    17  * This software may be distributed under the terms of the 
    18  * Q Public License, version 1.0 or later. 
    19  * http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     16 *   - Redistributions of source code must retain the above copyright 
     17 *     notice, this list of conditions and the following disclaimer. 
     18 *   - Redistributions in binary form must reproduce the above 
     19 *     copyright notice, this list of conditions and the following disclaimer 
     20 *     in the documentation and/or other materials provided with the 
     21 *     distribution. 
     22 *   - Neither the name of the Science & Technology Facilities Council 
     23 *     (STFC) nor the names of its contributors may be used to endorse or 
     24 *     promote products derived from this software without specific prior 
     25 *     written permission. 
     26 * 
     27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     38 *  
    2039 */ 
    2140 
     
    140159        } 
    141160         
    142         private String[] extractWordPhrase(String term) { 
     161        private String[] extractWordPhrase(String term) throws AssembleQueryException { 
    143162                List<String> ret = new ArrayList<String>(); 
    144163 
     
    169188                        if ((grouperIndex != -1 && spaceIndex == -1) 
    170189                                        || (grouperIndex != -1 && spaceIndex != -1 && grouperIndex < spaceIndex)) { 
    171                                 stop = findAssociator(term, start+2);                                    
     190                                stop = findAssociator(term, start+2); 
     191                                if (stop == -1) 
     192                                        throw new AssembleQueryException(new NdgMessage("term.target.syntax.error", new Object[] { term })); 
    172193                                ret.add("''" + term.substring(start+2, stop) + "''");    
    173194                                start = stop + 2; 
  • RevitalizationWS/common/core/trunk/src/test/java/ndg/common/TermParserTest.java

    r7269 r7616  
    7070                } 
    7171                 
     72                test = "and"; 
     73                try { 
     74                        tp.parseTerm(test); 
     75                } catch (AssembleQueryException e) { 
     76                        assertTrue(true); 
     77                        //has to fail 
     78                        //fail(new MessageFormatter().getFormattedText(e.getBundlMessage())); 
     79                }                
     80                 
     81                test = "\"\"cetaceus"; 
     82                try { 
     83                        tp.parseTerm(test); 
     84                } catch (AssembleQueryException e) { 
     85                        assertTrue(true); 
     86                        //has to fail 
     87                        //fail(new MessageFormatter().getFormattedText(e.getBundlMessage())); 
     88                }                
     89                 
     90                test = "cetaceus\"\""; 
     91                try { 
     92                        tp.parseTerm(test); 
     93                } catch (AssembleQueryException e) { 
     94                        assertTrue(true); 
     95                        //has to fail 
     96                        //fail(new MessageFormatter().getFormattedText(e.getBundlMessage())); 
     97                }                        
     98                 
    7299                test = "one & - two"; 
    73100                try { 
Note: See TracChangeset for help on using the changeset viewer.