incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r921452 - /incubator/aries/trunk/samples/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java
Date Wed, 10 Mar 2010 17:02:58 GMT
Author: zoe
Date: Wed Mar 10 17:02:58 2010
New Revision: 921452

URL: http://svn.apache.org/viewvc?rev=921452&view=rev
Log:
ARIES-236 Check the email address on creation

Modified:
    incubator/aries/trunk/samples/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java

Modified: incubator/aries/trunk/samples/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java?rev=921452&r1=921451&r2=921452&view=diff
==============================================================================
--- incubator/aries/trunk/samples/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java
(original)
+++ incubator/aries/trunk/samples/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java
Wed Mar 10 17:02:58 2010
@@ -66,6 +66,10 @@ public class EditAuthor extends HttpServ
       
       FormServlet.addError(req, "The email field is required.");
       resp.sendRedirect("EditAuthorForm");
+      
+    }else if (checkEmail(email) == null) {
+    	FormServlet.addError(req, "The email field is not properly formatted");
+        resp.sendRedirect("EditAuthorForm");	
     } else {
       BloggingService service = JNDIHelper.getBloggingService();
 
@@ -85,4 +89,10 @@ public class EditAuthor extends HttpServ
   {
     FormServlet.storeParam(req, EditAuthorForm.ID, param, value);
   }
+    
+    private String checkEmail(String parameter)
+    {
+      if (parameter != null && parameter.matches("^(?:[a-zA-Z0-9_'^&/+-])+(?:\\.(?:[a-zA-Z0-9_'^&/+-])+)*@(?:(?:\\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\]?)|(?:[a-zA-Z0-9-]+\\.)+(?:[a-zA-Z]){2,}\\.?)$"))
return parameter;
+      return null;
+    }
 }
\ No newline at end of file



Mime
View raw message