You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2012/07/10 19:07:45 UTC
svn commit: r1359788 - in /cxf/branches/2.6.x-fixes: ./
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/
rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Author: sergeyb
Date: Tue Jul 10 17:07:44 2012
New Revision: 1359788
URL: http://svn.apache.org/viewvc?rev=1359788&view=rev
Log:
Merged revisions 1359782,1359784 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1359782 | sergeyb | 2012-07-10 17:57:30 +0100 (Tue, 10 Jul 2012) | 1 line
[CXF-4415] Support for basic hierarchical queries
........
r1359784 | sergeyb | 2012-07-10 17:58:05 +0100 (Tue, 10 Jul 2012) | 1 line
[CXF-4415] Missing updates
........
Modified:
cxf/branches/2.6.x-fixes/ (props changed)
cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Merged /cxf/trunk:r1359782-1359784
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1359788&r1=1359787&r2=1359788&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java (original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java Tue Jul 10 17:07:44 2012
@@ -101,6 +101,7 @@ public final class InjectionUtils {
private static final String HTTP_SERVLET_RESPONSE_CLASS_NAME = "javax.servlet.http.HttpServletResponse";
private static final String PARAM_HANDLERS_FIRST = "check.parameter.handlers.first";
+ private static final String IGNORE_MATRIX_PARAMETERS = "ignore.matrix.parameters";
private InjectionUtils() {
@@ -289,12 +290,12 @@ public final class InjectionUtils {
if (value == null) {
return null;
}
-
if (pType == ParameterType.PATH) {
if (PathSegment.class.isAssignableFrom(pClass)) {
return pClass.cast(new PathSegmentImpl(value, decoded));
- } else {
- value = new PathSegmentImpl(value, false).getPath();
+ } else if (!MessageUtils.isTrue(
+ message.getContextualProperty(IGNORE_MATRIX_PARAMETERS))) {
+ value = new PathSegmentImpl(value, false).getPath();
}
}
Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java?rev=1359788&r1=1359787&r2=1359788&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java (original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java Tue Jul 10 17:07:44 2012
@@ -18,6 +18,10 @@
*/
package org.apache.cxf.jaxrs.ext.search;
+/**
+ * Search Language Parser implementation.
+ * FIQL Language parser is the default implementation.
+ */
public interface SearchConditionParser<T> {
SearchCondition<T> parse(String fiqlExpression) throws SearchParseException;
}
Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java?rev=1359788&r1=1359787&r2=1359788&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java (original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java Tue Jul 10 17:07:44 2012
@@ -19,12 +19,14 @@
package org.apache.cxf.jaxrs.ext.search;
/**
- * Represents the current search expression
+ * Represents the current search expression.
*/
public interface SearchContext {
/**
- * Returns the typed search condition representing the search expression
+ * Returns the typed search condition representing
+ * the search expression which is extracted from
+ * the request URI
*
* @param cls the type of the bean(s) the new search condition will
* attempt to match
@@ -34,8 +36,21 @@ public interface SearchContext {
/**
- * Returns the actual query expression
- * @return the expression
+ * Returns the typed search condition representing
+ * the provided search expression
+ *
+ * @param expression the search expression
+ * @param cls the type of the bean(s) the new search condition will
+ * attempt to match
+ * @return the search condition
+ */
+ <T> SearchCondition<T> getCondition(String expression, Class<T> cls);
+
+
+ /**
+ * Returns the search expression
+ * @return the expression which is extracted from
+ * the request URI, can be null
*/
String getSearchExpression();
}
Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java?rev=1359788&r1=1359787&r2=1359788&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java (original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java Tue Jul 10 17:07:44 2012
@@ -43,6 +43,10 @@ public class SearchContextImpl implement
}
public <T> SearchCondition<T> getCondition(Class<T> cls) {
+ return getCondition(null, cls);
+ }
+
+ public <T> SearchCondition<T> getCondition(String expression, Class<T> cls) {
if (InjectionUtils.isPrimitive(cls)) {
String errorMessage = "Primitive condition types are not supported";
@@ -52,10 +56,11 @@ public class SearchContextImpl implement
SearchConditionParser<T> parser = getParser(cls);
- String expression = getSearchExpression();
- if (expression != null) {
+ String theExpression = expression == null
+ ? getSearchExpression() : expression;
+ if (theExpression != null) {
try {
- return parser.parse(expression);
+ return parser.parse(theExpression);
} catch (SearchParseException ex) {
return null;
}
@@ -66,6 +71,7 @@ public class SearchContextImpl implement
}
public String getSearchExpression() {
+
String queryStr = (String)message.get(Message.QUERY_STRING);
if (queryStr != null
&& (queryStr.contains(SHORT_SEARCH_QUERY) || queryStr.contains(SEARCH_QUERY))) {
@@ -81,7 +87,7 @@ public class SearchContextImpl implement
}
}
- private <T> FiqlParser<T> getParser(Class<T> cls) {
+ private <T> SearchConditionParser<T> getParser(Class<T> cls) {
// we can use this method as a parser factory, ex
// we can get parsers capable of parsing XQuery and other languages
// depending on the properties set by a user
Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1359788&r1=1359787&r2=1359788&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Tue Jul 10 17:07:44 2012
@@ -560,23 +560,41 @@ public class BookStore {
}
@GET
- @Path("/books/{fiql}/chapter/{i}")
+ @Path("/books/{search}/chapter/{chapter}")
@Produces("application/xml")
- public Chapter getInChapterFromSelectedBook(@Context SearchContext searchContext,
- @PathParam("fiql") PathSegment fiqlSegment,
- @PathParam("i") int chapterIndex) throws BookNotFoundFault {
+ public Chapter getChapterFromSelectedBook(@Context SearchContext searchContext,
+ @PathParam("search") String expression,
+ @PathParam("chapter") int chapter) {
- SearchCondition<Book> sc = searchContext.getCondition(Book.class);
+ SearchCondition<Book> sc = searchContext.getCondition(expression, Book.class);
if (sc == null) {
- throw new BookNotFoundFault("Search exception");
+ throw new WebApplicationException(404);
}
List<Book> found = sc.findAll(books.values());
if (found.size() != 1) {
- throw new BookNotFoundFault("Single book is expected");
+ throw new WebApplicationException(404);
}
+ Book selectedBook = found.get(0);
- Book book = found.get(0);
- return book.getChapter(chapterIndex);
+ return selectedBook.getChapter(chapter);
+ }
+
+ @GET
+ @Path("/books({search})/chapter")
+ @Produces("application/xml")
+ public Chapter getIntroChapterFromSelectedBook(@Context SearchContext searchContext,
+ @PathParam("search") String expression) {
+
+ return getChapterFromSelectedBook(searchContext, expression, 1);
+ }
+
+ @GET
+ @Path("/books[{search}]/chapter")
+ @Produces("application/xml")
+ public Chapter getIntroChapterFromSelectedBook2(@Context SearchContext searchContext,
+ @PathParam("search") String expression) {
+
+ return getChapterFromSelectedBook(searchContext, expression, 1);
}
@GET
Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1359788&r1=1359787&r2=1359788&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Tue Jul 10 17:07:44 2012
@@ -72,11 +72,44 @@ public class JAXRSClientServerBookTest e
public static void startServers() throws Exception {
AbstractResourceInfo.clearAllMaps();
assertTrue("server did not launch correctly",
- launchServer(BookServer.class, true));
+ launchServer(BookServer.class));
createStaticBus();
}
@Test
+ public void testGetChapterFromSelectedBook() {
+ String address = "http://localhost:" + PORT + "/bookstore/books/id=le=123/chapter/1";
+ doTestGetChapterFromSelectedBook(address);
+ }
+
+ @Test
+ public void testGetIntroChapterFromSelectedBook() {
+ String address = "http://localhost:" + PORT + "/bookstore/books(id=le=123)/chapter";
+ doTestGetChapterFromSelectedBook(address);
+ }
+
+ @Test
+ public void testGetIntroChapterFromSelectedBook2() {
+ String address = "http://localhost:" + PORT + "/bookstore/";
+ WebClient wc = WebClient.create(address);
+ wc.path("books[id=le=123]");
+ wc.path("chapter");
+ wc.accept("application/xml");
+ Chapter chapter = wc.get(Chapter.class);
+ assertEquals("chapter 1", chapter.getTitle());
+ }
+
+ private void doTestGetChapterFromSelectedBook(String address) {
+
+ WebClient wc =
+ WebClient.create(address);
+ WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000);
+ wc.accept("application/xml");
+ Chapter chapter = wc.get(Chapter.class);
+ assertEquals("chapter 1", chapter.getTitle());
+ }
+
+ @Test
public void testWithComplexPath() {
WebClient wc =
WebClient.create("http://localhost:" + PORT + "/bookstore/allCharsButA-B/:@!$&'()*+,;=-._~");