From: <fg...@us...> - 2010-08-29 07:10:00
|
Revision: 2920 http://openutils.svn.sourceforge.net/openutils/?rev=2920&view=rev Author: fgiust Date: 2010-08-29 07:09:52 +0000 (Sun, 29 Aug 2010) Log Message: ----------- CRIT-20 workaround for https://issues.apache.org/jira/browse/JCR-2732 Modified Paths: -------------- trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/advanced/XpathEscapeTest.java Modified: trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java =================================================================== --- trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java 2010-08-28 13:18:46 UTC (rev 2919) +++ trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java 2010-08-29 07:09:52 UTC (rev 2920) @@ -29,7 +29,7 @@ * @author fgrilli * @version $Id$ */ -public class XPathTextUtils +public final class XPathTextUtils { private static final Logger log = LoggerFactory.getLogger(XPathTextUtils.class); @@ -45,10 +45,11 @@ * A search string like 'test?' will run into a ParseException documented in * http://issues.apache.org/jira/browse/JCR-1248 This is copied from org.apache.jackrabbit.util.Text and was put * here just to keep this API JCR implementation agnostic - * @param string the string to encode + * @param s the string to encode * @return the escaped string * @deprecated may cause JCRQueryException on search-expressions like "\"milano\"" (CRIT-9) */ + @Deprecated public static String escapeIllegalXpathSearchChars(String s) { if (StringUtils.isEmpty(s)) @@ -113,6 +114,9 @@ */ String parseString = StringUtils.trimToEmpty(str); + // workaround for https://issues.apache.org/jira/browse/JCR-2732 + parseString = StringUtils.replaceEach(parseString, new String[]{":)", ":(" }, new String[]{": )", ": (" }); + /* * http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Escaping%20Special%20Characters * http://www.javalobby.org/java/forums/t86124.html @@ -131,7 +135,7 @@ } /** - * @param String path to encode eg //my//path/2009//* + * @param path to encode eg //my//path/2009//* * @return String encoded path eg //my//path/_x0032_009//* */ public static String encodeDigitsInPath(String path) Modified: trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/advanced/XpathEscapeTest.java =================================================================== --- trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/advanced/XpathEscapeTest.java 2010-08-28 13:18:46 UTC (rev 2919) +++ trunk/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/advanced/XpathEscapeTest.java 2010-08-29 07:09:52 UTC (rev 2920) @@ -81,6 +81,9 @@ Assert.fail("Invalid query"); } Assert.assertNotNull(advResult); + + Assert.assertEquals(advResult.getFirstResult().getTitle(), title); + Collection< ? extends Content> collection = CriteriaTestUtils.collectCollectionFromResult(advResult); Assert.assertEquals(collection.size(), 1); for (Content content : collection) @@ -380,8 +383,6 @@ } - // broken in jackrabbit 2.0/2.1 - @Test(enabled = false) public void testSmile() { @@ -391,8 +392,8 @@ criteria.setBasePath(StringUtils.EMPTY); criteria.add(Restrictions.contains("@title", searchText)); - // TODO: doesn't work with jackrabbit 2, to be fixed - Assert.assertEquals(criteria.toXpathExpression(), "//*[( ( jcr:contains(@title, '\\:\\)') ) )] "); + // the space is added as a workaround + Assert.assertEquals(criteria.toXpathExpression(), "//*[( ( jcr:contains(@title, '\\: \\)') ) )] "); AdvancedResult advResult = criteria.execute(); Collection< ? extends Content> result = CriteriaTestUtils.collectCollectionFromResult(advResult); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |