Author: buildbot
Date: Sat Nov 30 20:47:53 2013
New Revision: 888645

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/validationfeature.html

Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/cxf/content/docs/validationfeature.html
==============================================================================
--- websites/production/cxf/content/docs/validationfeature.html (original)
+++ websites/production/cxf/content/docs/validationfeature.html Sat Nov 30 
20:47:53 2013
@@ -132,12 +132,12 @@ Apache CXF -- ValidationFeature
 <div id="ConfluenceContent"><p><span style="font-size:2em;font-weight:bold"> 
Bean Validation Feature </span></p>
 
 <div>
-<ul><ul><li><a shape="rect" 
href="#ValidationFeature-Introduction">Introduction</a></li><li><a shape="rect" 
href="#ValidationFeature-Dependencies">Dependencies</a></li><ul><li><a 
shape="rect" 
href="#ValidationFeature-UsingHibernateValidatorasbeanvalidationprovider">Using 
Hibernate Validator as bean validation provider</a></li><li><a shape="rect" 
href="#ValidationFeature-UsingApacheBValasbeanvalidationprovider">Using Apache 
BVal as bean validation provider</a></li></ul></ul><li><a shape="rect" 
href="#ValidationFeature-BeanValidation1.1andJAXRS2.0integration">Bean 
Validation 1.1 and JAX-RS 2.0 integration</a></li><ul><li><a shape="rect" 
href="#ValidationFeature-ConfiguringBeanValidation1.1usingJAXRSServerFactoryBean">Configuring
 Bean Validation 1.1 using JAXRSServerFactoryBean</a></li><li><a shape="rect" 
href="#ValidationFeature-ConfiguringBeanValidation1.1usingSpringbeandefinitionsXML">Configuring
 Bean Validation 1.1 using Spring bean definitions XML</a></li><li><a 
shape="rect" href=
 "#ValidationFeature-ValidationExceptionsandHTTPstatuscodes">Validation 
Exceptions and HTTP status codes</a></li></ul></ul></div>
+<ul><li><a shape="rect" 
href="#ValidationFeature-Introduction">Introduction</a></li><li><a shape="rect" 
href="#ValidationFeature-Dependencies">Dependencies</a></li><ul><li><a 
shape="rect" 
href="#ValidationFeature-UsingHibernateValidatorasbeanvalidationprovider">Using 
Hibernate Validator as bean validation provider</a></li><li><a shape="rect" 
href="#ValidationFeature-UsingApacheBValasbeanvalidationprovider">Using Apache 
BVal as bean validation provider</a></li></ul><li><a shape="rect" 
href="#ValidationFeature-BeanValidation1.1andJAXRS2.0integration">Bean 
Validation 1.1 and JAX-RS 2.0 integration</a></li><ul><li><a shape="rect" 
href="#ValidationFeature-ConfiguringBeanValidation1.1usingJAXRSServerFactoryBean">Configuring
 Bean Validation 1.1 using JAXRSServerFactoryBean</a></li><li><a shape="rect" 
href="#ValidationFeature-ConfiguringBeanValidation1.1usingSpringbeandefinitionsXML">Configuring
 Bean Validation 1.1 using Spring bean definitions XML</a></li><li><a 
shape="rect" href="#Validat
 ionFeature-ValidationExceptionsandHTTPstatuscodes">Validation Exceptions and 
HTTP status codes</a></li></ul><li><a shape="rect" 
href="#ValidationFeature-Examples">Examples</a></li><ul><li><a shape="rect" 
href="#ValidationFeature-Validatingsimpleinputparameters">Validating simple 
input parameters</a></li><li><a shape="rect" 
href="#ValidationFeature-Validatingcomplexinputparameters">Validating complex 
input parameters</a></li><li><a shape="rect" 
href="#ValidationFeature-Validatingreturnvalues%28nonResponse%29">Validating 
return values (non-Response)</a></li><li><a shape="rect" 
href="#ValidationFeature-Validatingreturnvalues%28Response%29">Validating 
return values (Response)</a></li></ul></ul></div>
 
-<h2><a shape="rect" name="ValidationFeature-Introduction"></a>Introduction</h2>
+<h1><a shape="rect" name="ValidationFeature-Introduction"></a>Introduction</h1>
 <p>Among many other features, JAX-RS 2.0 specification introduces Bean 
Validation 1.1 support as a mandatory part of implementation. In an effort to 
fulfill this requirement, Apache CXF provides full-fledge validation support 
for JAX-RS / JAX-WS endpoints, both for request parameters and response 
values.</p>
 
-<h2><a shape="rect" name="ValidationFeature-Dependencies"></a>Dependencies</h2>
+<h1><a shape="rect" name="ValidationFeature-Dependencies"></a>Dependencies</h1>
 <p>Bean Validation support in Apache CXF is implementation-independent and is 
built solely using API. As such, the only required dependency is:</p>
 <div class="preformatted panel" style="border-width: 1px;"><div 
class="preformattedContent panelContent">
 <pre>&lt;dependency&gt;
@@ -150,7 +150,7 @@ Apache CXF -- ValidationFeature
 
 <p>API doesn't provide implementation but there are couple of choices to pick 
from. Please notice that bean validation implementation is taken from the ones 
present in classpath. If no implementation is detected, bean validation is not 
available for use and constraints validation won't have any effect. </p>
 
-<h3><a shape="rect" 
name="ValidationFeature-UsingHibernateValidatorasbeanvalidationprovider"></a>Using
 Hibernate Validator as bean validation provider</h3>
+<h2><a shape="rect" 
name="ValidationFeature-UsingHibernateValidatorasbeanvalidationprovider"></a>Using
 Hibernate Validator as bean validation provider</h2>
 <p><a shape="rect" class="external-link" 
href="http://www.hibernate.org/subprojects/validator.html"; 
rel="nofollow">http://www.hibernate.org/subprojects/validator.html</a></p>
 
 <p>Hibernate Validator is mature and feature-rich validation provider with 
full support of Bean Validation 1.1 (as of version 5.x.x which is the reference 
implementation for JSR 349 - Bean Validation 1.1 API). To use Hibernate 
Validator in your Apache CXF projects, couple of additional dependencies should 
be included:</p>
@@ -178,7 +178,7 @@ Apache CXF -- ValidationFeature
 
 <p>Hibernate Validator uses Java Expression Language 3.0 in order to provide 
better validation messages support so the respective EL 3.0 API and 
implementation dependencies should be included.  </p>
 
-<h3><a shape="rect" 
name="ValidationFeature-UsingApacheBValasbeanvalidationprovider"></a>Using 
Apache BVal as bean validation provider</h3>
+<h2><a shape="rect" 
name="ValidationFeature-UsingApacheBValasbeanvalidationprovider"></a>Using 
Apache BVal as bean validation provider</h2>
 <p><a shape="rect" class="external-link" 
href="http://bval.apache.org/";>http://bval.apache.org/</a></p>
 
 <p>Current stable version of Apache BVal (0.5) doesn't support Bean Validation 
1.1 but the upcoming 1.1.0 should have it fully implemented (at the moment 
1.1.0-alpha-SNAPSHOT could be used).</p>
@@ -253,7 +253,80 @@ sf.create();
 <h2><a shape="rect" 
name="ValidationFeature-ValidationExceptionsandHTTPstatuscodes"></a>Validation 
Exceptions and HTTP status codes</h2>
 
 <p>As per JAX-RS 2.0 specification, any input parameter validation violation 
is mapped to HTTP status code 400 Bad Request and any return value validation 
violation (or internal validation violation) is mapped to HTTP status code 500 
Internal Server Error. This is essentially what 
org.apache.cxf.jaxrs.validation.ValidationExceptionMapper does.</p>
-<div class="panelMacro"><table class="noteMacro"><colgroup span="1"><col 
span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" 
valign="top"><img align="middle" 
src="https://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif"; 
width="16" height="16" alt="" border="0"></td><td colspan="1" rowspan="1">At 
the moment, the details of validation exceptions are not included into the 
response. The reason why is that error reporting logic is application-specific 
and may vary from application to application (f.e. it could be simple 
'text/html' with error message, or 'application/json', or HTTP custom headers, 
...). Application developers are encouraged to provide own implementation of 
this particular functionality.</td></tr></table></div></div>
+<div class="panelMacro"><table class="noteMacro"><colgroup span="1"><col 
span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" 
valign="top"><img align="middle" 
src="https://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif"; 
width="16" height="16" alt="" border="0"></td><td colspan="1" rowspan="1">At 
the moment, the details of validation exceptions are not included into the 
response. The reason why is that error reporting logic is application-specific 
and may vary from application to application (f.e. it could be simple 
'text/html' with error message, or 'application/json', or HTTP custom headers, 
...). Application developers are encouraged to provide own implementation of 
this particular functionality.</td></tr></table></div>
+
+<h1><a shape="rect" name="ValidationFeature-Examples"></a>Examples</h1>
+
+<p>You can use any predefined validation annotation as well as define your own 
as far as it follows Bean Validation 1.1 specification. This section includes 
couple of typical scenarios.</p>
+
+<h2><a shape="rect" 
name="ValidationFeature-Validatingsimpleinputparameters"></a>Validating simple 
input parameters</h2>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
+@POST
+@Path("/books")
+public Response addBook(
+        @NotNull @Pattern(regexp = "\\d+") @FormParam("id") String id,
+        @NotNull @Size(min = 1, max = 50) @FormParam("name") String name) {
+    // ...
+}
+]]></script>
+</div></div>
+
+<h2><a shape="rect" 
name="ValidationFeature-Validatingcomplexinputparameters"></a>Validating 
complex input parameters</h2>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
+@POST
+@Path("/books")
+public Response addBook( @Valid Book book ) {
+    // ...
+}
+]]></script>
+</div></div>
+
+<p>This example assumes that class Book has validation constraints defined, 
f.e.:</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
+public class Book {
+    @NotNull @Pattern(regexp = "\\d+") private String id;
+    @NotNull @Size(min = 1, max = 50) private String name;
+
+    // ...
+}
+]]></script>
+</div></div>
+
+<h2><a shape="rect" 
name="ValidationFeature-Validatingreturnvalues%28nonResponse%29"></a>Validating 
return values (non-Response)</h2>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
+@GET
+@Path("/books/{bookId}")
+@Override    
+@NotNull @Valid
+public Book getBook(@PathParam("bookId") String id) {
+    // ...     
+}
+]]></script>
+</div></div>
+
+<p>This example assumes that class Book has validation constraints defined (as 
in example above).</p>
+
+<h2><a shape="rect" 
name="ValidationFeature-Validatingreturnvalues%28Response%29"></a>Validating 
return values (Response)</h2>
+
+<p>Returning Response object stands aside from all other usage scenarios. 
Usually, Response is a holder for another object (entity) but because Response 
has no validation constraints defined, the inner object (entity) is not 
validatable even if it has full set of validation constraints . Unfortunately, 
this particular use case is not described in JAX-RS 2.0 specification. 
Nevertheless, Apache CXF team thinks that such a validation would be beneficial 
and performs a simple trick: whenever Response is being returned, all defined 
for it validation constraints will be applied not to Response instance itself 
but to the entity it holds.</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
+@GET
+@Path("/books/{bookId}")
+@Valid @NotNull
+public Response getBookResponse(@PathParam("bookId") String id) {
+    return Response.ok( new Book( id ) ).build();
+}
+]]></script>
+</div></div></div>
            </div>
            <!-- Content -->
          </td>


Reply via email to