Revision: 9124
Author: [email protected]
Date: Tue Oct 19 19:17:47 2010
Log: roll back 17758916

Public: roll back patch that broke the build

Review at http://gwt-code-reviews.appspot.com/1033801

Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=9124

Deleted:
/trunk/samples/validation/src/com/google/gwt/sample/validation/shared/ClientGroup.java /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/ServerConstraint.java /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/ServerGroup.java /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/ServerValidator.java
 /trunk/samples/validation/src/com/google/gwt/sample/validation/super
/trunk/user/src/javax/validation/ConstraintViolationException_CustomFieldSerializer.java
 /trunk/user/src/org/hibernate/validator/engine
/trunk/user/src/org/hibernate/validator/super/org/hibernate/validator/engine
Modified:
 /trunk/samples/validation/build.xml
/trunk/samples/validation/src/com/google/gwt/sample/validation/Validation.gwt.xml /trunk/samples/validation/src/com/google/gwt/sample/validation/client/GreetingService.java /trunk/samples/validation/src/com/google/gwt/sample/validation/client/GreetingServiceAsync.java /trunk/samples/validation/src/com/google/gwt/sample/validation/client/SampleValidator.java /trunk/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.java /trunk/samples/validation/src/com/google/gwt/sample/validation/server/GreetingServiceImpl.java /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/NoOp.java /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/Person.java
 /trunk/user/build.xml
 /trunk/user/src/org/hibernate/validator/HibernateValidator.gwt.xml

=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/ClientGroup.java Tue Oct 19 13:41:09 2010
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.sample.validation.shared;
-
-/**
- * Client Validation Group
- */
-public interface ClientGroup {
-}
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/ServerConstraint.java Tue Oct 19 13:41:09 2010
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.sample.validation.shared;
-
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.CONSTRUCTOR;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.validation.Constraint;
-import javax.validation.Payload;
-
-/**
- * Sample constraint that is designed to only run on the server. It will fail if
- * the Persons name is "Fail"
- */
-...@target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE})
-...@retention(RUNTIME)
-...@documented
-...@constraint(validatedBy = {ServerValidator.class})
-public @interface ServerConstraint {
-  String message() default "Not valid at the server";
-
-  Class<?>[] groups() default {};
-
-  Class<? extends Payload>[] payload() default {};
-}
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/ServerGroup.java Tue Oct 19 13:41:09 2010
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.sample.validation.shared;
-
-/**
- * Server Validation Group
- */
-public interface ServerGroup {
-}
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/ServerValidator.java Tue Oct 19 13:41:09 2010
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.sample.validation.shared;
-
-import java.lang.reflect.Method;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-
-/**
- * Fails only on the server if the persons name is "Fail"
- */
-public class ServerValidator implements
-    ConstraintValidator<ServerConstraint, Person> {
-
-  public void initialize(ServerConstraint constraintAnnotation) {
-    // Here I do something that will not compile on GWT
-    Method[] methods = constraintAnnotation.getClass().getMethods();
-  }
-
- public boolean isValid(Person person, ConstraintValidatorContext context) {
-    if (person == null) {
-      return true;
-    }
-    String name = person.getName();
-    return name == null || !name.equals("Fail");
-  }
-}
=======================================
--- /trunk/user/src/javax/validation/ConstraintViolationException_CustomFieldSerializer.java Tue Oct 19 13:41:09 2010
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package javax.validation;
-
-import com.google.gwt.user.client.rpc.SerializationException;
-import com.google.gwt.user.client.rpc.SerializationStreamReader;
-import com.google.gwt.user.client.rpc.SerializationStreamWriter;
-
-import java.util.Set;
-
-/**
- * Custom Serializer for {...@link ConstraintViolationException}.
- */
-public class ConstraintViolationException_CustomFieldSerializer {
-
-  public static void deserialize(SerializationStreamReader streamReader,
- ConstraintViolationException instance) throws SerializationException {
-    // no fields
-  }
-
-  public static ConstraintViolationException instantiate(
-      SerializationStreamReader streamReader)
-      throws SerializationException {
-    String message = streamReader.readString();
-    @SuppressWarnings("unchecked")
- Set<ConstraintViolation<?>> set = (Set<ConstraintViolation<?>>) streamReader.readObject();
-    return new ConstraintViolationException(message, set);
-  }
-
-  public static void serialize(SerializationStreamWriter streamWriter,
- ConstraintViolationException instance) throws SerializationException {
-    streamWriter.writeString(instance.getMessage());
-    streamWriter.writeObject(instance.getConstraintViolations());
-  }
-}
=======================================
--- /trunk/samples/validation/build.xml Tue Oct 19 13:41:09 2010
+++ /trunk/samples/validation/build.xml Tue Oct 19 19:17:47 2010
@@ -24,10 +24,5 @@
     <include name="apache/log4j/log4j-1.2.16.jar" />
     <include name="slf4j/slf4j-api/slf4j-api-1.6.1.jar" />
     <include name="slf4j/slf4j-log4j12/slf4j-log4j12-1.6.1.jar" />
-    <!-- Needed for JDK 1.5-->
-    <include name="javax/activation/activation-1.1.jar" />
-    <include name="javax/xml/bind/jaxb-api-2.1.jar" />
-    <include name="sun/jaxb/jaxb-impl-2.1.3.jar" />
-    <include name="javax/xml/stream/stax-api-1.0-2.jar" />
   </fileset>
 </project>
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/Validation.gwt.xml Tue Oct 19 13:41:09 2010 +++ /trunk/samples/validation/src/com/google/gwt/sample/validation/Validation.gwt.xml Tue Oct 19 19:17:47 2010
@@ -22,5 +22,4 @@

   <source path='client'/>
   <source path='shared'/>
-  <super-source path="super" />
 </module>
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/client/GreetingService.java Tue Oct 19 13:41:09 2010 +++ /trunk/samples/validation/src/com/google/gwt/sample/validation/client/GreetingService.java Tue Oct 19 19:17:47 2010
@@ -16,17 +16,13 @@
 package com.google.gwt.sample.validation.client;

 import com.google.gwt.rpc.client.RpcService;
-import com.google.gwt.safehtml.shared.SafeHtml;
 import com.google.gwt.sample.validation.shared.Person;
 import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

-import javax.validation.ConstraintViolationException;
-
 /**
  * The client side stub for the RPC service.
  */
 @RemoteServiceRelativePath("greet")
 public interface GreetingService extends RpcService {
-  SafeHtml greetServer(Person name) throws IllegalArgumentException,
-      ConstraintViolationException;
-}
+  String greetServer(Person name) throws IllegalArgumentException;
+}
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/client/GreetingServiceAsync.java Tue Oct 19 13:41:09 2010 +++ /trunk/samples/validation/src/com/google/gwt/sample/validation/client/GreetingServiceAsync.java Tue Oct 19 19:17:47 2010
@@ -15,16 +15,13 @@
  */
 package com.google.gwt.sample.validation.client;

-import com.google.gwt.safehtml.shared.SafeHtml;
 import com.google.gwt.sample.validation.shared.Person;
 import com.google.gwt.user.client.rpc.AsyncCallback;

-import javax.validation.ConstraintViolationException;
-
 /**
  * The async counterpart of <code>GreetingService</code>.
  */
 public interface GreetingServiceAsync {
-  void greetServer(Person person, AsyncCallback<SafeHtml> callback)
-      throws IllegalArgumentException, ConstraintViolationException;
-}
+  void greetServer(Person person, AsyncCallback<String> callback)
+      throws IllegalArgumentException;
+}
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/client/SampleValidator.java Tue Oct 19 13:41:09 2010 +++ /trunk/samples/validation/src/com/google/gwt/sample/validation/client/SampleValidator.java Tue Oct 19 19:17:47 2010
@@ -15,7 +15,6 @@
  */
 package com.google.gwt.sample.validation.client;

-import com.google.gwt.sample.validation.shared.ClientGroup;
 import com.google.gwt.sample.validation.shared.Person;
 import com.google.gwt.validation.client.GwtValidation;

@@ -28,6 +27,17 @@
  */
 @GwtValidation(value = Person.class,
  groups = {
-    Default.class, ClientGroup.class})
+    Default.class, SampleValidator.ClientGroup.class})
 public interface SampleValidator extends Validator {
-}
+  /**
+   * Client Validation Group
+   */
+  public interface ClientGroup {
+  }
+
+  /**
+   * Server Validation Group
+   */
+  public interface ServerGroup {
+  }
+}
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.java Tue Oct 19 13:41:09 2010 +++ /trunk/samples/validation/src/com/google/gwt/sample/validation/client/ValidationView.java Tue Oct 19 19:17:47 2010
@@ -20,7 +20,6 @@
 import com.google.gwt.event.dom.client.KeyCodes;
 import com.google.gwt.event.dom.client.KeyUpEvent;
 import com.google.gwt.resources.client.CssResource;
-import com.google.gwt.safehtml.shared.SafeHtml;
 import com.google.gwt.sample.validation.shared.Person;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
@@ -37,7 +36,6 @@
 import java.util.Set;

 import javax.validation.ConstraintViolation;
-import javax.validation.ConstraintViolationException;
 import javax.validation.Validator;

 /**
@@ -126,6 +124,7 @@
     person.setName(nameField.getText());

     Validator validator = GWT.create(SampleValidator.class);
+
Set<ConstraintViolation<Person>> violations = validator.validate(person);
     if (!violations.isEmpty()) {
       StringBuffer errorMessage = new StringBuffer();
@@ -141,24 +140,8 @@
     sendButton.setEnabled(false);
     textToServer.setText(person.getName());
     serverResponse.setText("");
-    greetingService.greetServer(person, new AsyncCallback<SafeHtml>() {
+    greetingService.greetServer(person, new AsyncCallback<String>() {
       public void onFailure(Throwable caught) {
-        if (caught instanceof ConstraintViolationException) {
- ConstraintViolationException violationException = (ConstraintViolationException) caught; - Set<ConstraintViolation<?>> violations = violationException.getConstraintViolations();
-          StringBuffer sb = new StringBuffer();
-          for (ConstraintViolation<?> constraintViolation : violations) {
-            sb.append(constraintViolation.getPropertyPath().toString()) //
-            .append(":") //
-            .append(constraintViolation.getMessage()) //
-            .append("\n");
-          }
-          errorLabel.setText(sb.toString());
-          sendButton.setEnabled(true);
-          sendButton.setFocus(true);
-          return;
-        }
-
         // Show the RPC error message to the user
         dialogBox.setText("Remote Procedure Call - Failure");
         serverResponse.addStyleName(style.error());
@@ -167,7 +150,7 @@
         closeButton.setFocus(true);
       }

-      public void onSuccess(SafeHtml result) {
+      public void onSuccess(String result) {
         dialogBox.setText("Remote Procedure Call");
         serverResponse.removeStyleName(style.error());
         serverResponse.setHTML(result);
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/server/GreetingServiceImpl.java Tue Oct 19 13:41:09 2010 +++ /trunk/samples/validation/src/com/google/gwt/sample/validation/server/GreetingServiceImpl.java Tue Oct 19 19:17:47 2010
@@ -16,20 +16,8 @@
 package com.google.gwt.sample.validation.server;

 import com.google.gwt.rpc.server.RpcServlet;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
 import com.google.gwt.sample.validation.client.GreetingService;
 import com.google.gwt.sample.validation.shared.Person;
-import com.google.gwt.sample.validation.shared.ServerGroup;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.validation.ConstraintViolation;
-import javax.validation.ConstraintViolationException;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.groups.Default;

 /**
  * The server side implementation of the RPC service.
@@ -38,33 +26,35 @@
 public class GreetingServiceImpl extends RpcServlet implements
     GreetingService {

- private final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
-
- public SafeHtml greetServer(Person person) throws IllegalArgumentException,
-      ConstraintViolationException {
+ public String greetServer(Person person) throws IllegalArgumentException {
     // Verify that the input is valid.
- Set<ConstraintViolation<Person>> violations = validator.validate(person,
-        Default.class, ServerGroup.class);
-    if (!violations.isEmpty()) {
- Set<ConstraintViolation<?>> temp = new HashSet<ConstraintViolation<?>>(
-          violations);
-      throw new ConstraintViolationException(temp);
-    }
+
+    // TODO(nchalko) validate

     String serverInfo = getServletContext().getServerInfo();
     String userAgent = getThreadLocalRequest().getHeader("User-Agent");

// Escape data from the client to avoid cross-site script vulnerabilities.
-    SafeHtmlBuilder builder = new SafeHtmlBuilder();
-
-    SafeHtml safeHtml = builder//
-    .appendEscapedLines("Hello, " + person.getName() + "!")//
-    .appendHtmlConstant("<br>")//
-    .appendEscaped("I am running " + serverInfo + ".")//
-    .appendHtmlConstant("<br><br>")//
-    .appendEscaped("It looks like you are using: ")//
-    .appendEscaped(userAgent)//
-    .toSafeHtml();
-    return safeHtml;
+    String value = escapeHtml(person.getName());
+    userAgent = escapeHtml(userAgent);
+
+    return "Hello, " + value + "!<br><br>I am running " + serverInfo
+        + ".<br><br>It looks like you are using:<br>" + userAgent;
+  }
+
+  /**
+   * Escape an html string. Escaping data received from the client helps to
+   * prevent cross-site script vulnerabilities.
+   *
+   * @param html the html string to escape
+   * @return the escaped string
+   */
+  private String escapeHtml(String html) {
+    // TODO(nchalko) use SafeHtml after it's integrated.
+    if (html == null) {
+      return null;
+    }
+ return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(
+        ">", "&gt;");
   }
 }
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/NoOp.java Tue Oct 19 13:41:09 2010 +++ /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/NoOp.java Tue Oct 19 19:17:47 2010
@@ -31,7 +31,7 @@
 import javax.validation.Payload;

 /**
- * Test constraint that is always valid
+ * Test constaint that is always valid
  */
 @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE})
 @Retention(RUNTIME)
=======================================
--- /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/Person.java Tue Oct 19 13:41:09 2010 +++ /trunk/samples/validation/src/com/google/gwt/sample/validation/shared/Person.java Tue Oct 19 19:17:47 2010
@@ -23,7 +23,7 @@
 /**
  * A sample bean to show validation on.
  */
-...@serverconstraint(groups = ServerGroup.class)
+...@noop
 public class Person implements IsSerializable {

   @NotNull
=======================================
--- /trunk/user/build.xml       Tue Oct 19 13:41:09 2010
+++ /trunk/user/build.xml       Tue Oct 19 19:17:47 2010
@@ -146,7 +146,7 @@
<exclude name="javax/validation/super/javax/validation/MessageInterpolator.java"/> <exclude name="javax/validation/super/javax/validation/Configuration.java"/> <exclude name="javax/validation/super/javax/validation/Validation.java"/> - <exclude name="org/hibernate/validator/super/org/hibernate/validator/**/*.java"/> + <exclude name="org/hibernate/validator/super/org/hibernate/validator/constraints/ScriptAssert.java"/>
       </fileset>
       <fileset dir="super/com/google/gwt/emul" />
       <fileset dir="super/com/google/gwt/junit/translatable" />
=======================================
--- /trunk/user/src/org/hibernate/validator/HibernateValidator.gwt.xml Tue Oct 19 13:41:09 2010 +++ /trunk/user/src/org/hibernate/validator/HibernateValidator.gwt.xml Tue Oct 19 19:17:47 2010
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module>
-<!--
-Import this module to use Hibernate Validator during the compilation of validation classes for
+<!--
+Import this module to use Hibernate Validator during the compilation of validation classes for
 gwt clients.
  -->
   <inherits name='com.google.gwt.validation.Validation' />
@@ -10,9 +10,7 @@
     <exclude name="super/" />
   </source>
   <source path="engine">
-    <include name="ConstraintViolationImpl.java"/>
     <include name="NodeImpl.java"/>
-    <include name="PathImpl.java"/>
   </source>
   <super-source path="super" />
 </module>

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to