You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2014/08/04 12:20:58 UTC

[1/2] git commit: WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Repository: wicket
Updated Branches:
  refs/heads/wicket-6.x 9fb48d836 -> f7e66e61e


WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Remove the newly introduced CookieUtils#loadValues() method.
At http://markmail.org/message/6t5gaeb3c2h24r36 we decided to deprecate all multivalue related methods in 6.x and remove them in 7.x


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/89ce5c41
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/89ce5c41
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/89ce5c41

Branch: refs/heads/wicket-6.x
Commit: 89ce5c41be76ea7a7c9c4679e419c15d83aaed07
Parents: 9fb48d8
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Aug 4 12:09:52 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Aug 4 12:09:52 2014 +0200

----------------------------------------------------------------------
 .../apache/wicket/util/cookies/CookieUtils.java  | 19 -------------------
 .../wicket/util/cookies/CookieUtilsTest.java     | 18 ------------------
 2 files changed, 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/89ce5c41/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
index af2d26e..0f1f315 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
@@ -123,25 +123,6 @@ public class CookieUtils
 	}
 
 	/**
-	 * Retrieve an array of the cookie value split by {@link org.apache.wicket.markup.html.form.FormComponent#VALUE_SEPARATOR}.
-	 *
-	 * @param key
-	 *          The cookie name
-	 * @return The cookie value split by {@link org.apache.wicket.markup.html.form.FormComponent#VALUE_SEPARATOR}.
-	 */
-	public final String[] loadValues(final String key)
-	{
-		final Cookie cookie = getCookie(key);
-		if (cookie != null)
-		{
-			String value = cookie.getValue();
-			String[] values = splitValue(value);
-			return values;
-		}
-		return null;
-	}
-
-	/**
 	 * Retrieve the cookie value associated with the formComponent and load the model object with
 	 * the cookie value.
 	 * 

http://git-wip-us.apache.org/repos/asf/wicket/blob/89ce5c41/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
index 2068cf4..9e6cf40 100644
--- a/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/util/cookies/CookieUtilsTest.java
@@ -17,10 +17,8 @@
 package org.apache.wicket.util.cookies;
 
 import static org.hamcrest.Matchers.arrayContaining;
-import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.emptyArray;
 import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.equalToIgnoringCase;
 import static org.hamcrest.Matchers.is;
 
 import java.util.Arrays;
@@ -35,8 +33,6 @@ import org.apache.wicket.WicketTestCase;
 import org.apache.wicket.markup.html.form.FormComponent;
 import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.util.cookies.CookieValuePersisterTestPage.TestForm;
-import org.apache.wicket.util.string.Strings;
-import org.hamcrest.Matchers;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -192,20 +188,6 @@ public class CookieUtilsTest extends WicketTestCase
 	}
 
 	@Test
-	public void saveLoadValues()
-	{
-		CookieUtils utils = new CookieUtils();
-		String value1 = "value one";
-		String value2 = "value two";
-		String value3 = "value three";
-		String key = "key";
-		utils.save(key, value1, value2, value3);
-		before(); // execute a request cycle, so the response cookie is send with the next request
-		String[] result = utils.loadValues(key);
-		assertThat(result, is(Matchers.arrayContaining(value1, value2, value3)));
-	}
-
-	@Test
 	public void defaults()
 	{
 		CookieDefaults defaults = new CookieDefaults();


[2/2] git commit: WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Posted by mg...@apache.org.
WICKET-5648 CookieUtils - add #loadValues(), make #getCookie() public, properly initialize from the defaults

Deprecate all multivalue related methods.
It is not possible to deprecate #save(Strng key, String... values) because most of the time it is used by the applications as #save(key, value)


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/f7e66e61
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/f7e66e61
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/f7e66e61

Branch: refs/heads/wicket-6.x
Commit: f7e66e61e3097d32b7767890208436b508747ef1
Parents: 89ce5c4
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Aug 4 12:12:34 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Aug 4 12:12:34 2014 +0200

----------------------------------------------------------------------
 .../org/apache/wicket/util/cookies/CookieUtils.java    | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/f7e66e61/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
index 0f1f315..1859d96 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java
@@ -135,7 +135,7 @@ public class CookieUtils
 		if (value != null)
 		{
 			// Assign the retrieved/persisted value to the component
-			formComponent.setModelValue(splitValue(value));
+			formComponent.setModelValue(new String[] {value});
 		}
 		return value;
 	}
@@ -145,7 +145,9 @@ public class CookieUtils
 	 * 
 	 * @param value
 	 * @return The cookie's value split into fragments
+	 * @deprecated Cookies with multiple values are no more supported (WICKET-5648). This method will be removed in Wicket 7.x
 	 */
+	@Deprecated
 	protected String[] splitValue(final String value)
 	{
 		return Strings.split(value, FormComponent.VALUE_SEPARATOR.charAt(0));
@@ -156,7 +158,9 @@ public class CookieUtils
 	 * 
 	 * @param values
 	 * @return The cookie's value split into its constituent parts
+	 * @deprecated Cookies with multiple values are no more supported (WICKET-5648). This method will be removed in Wicket 7.x
 	 */
+	@Deprecated
 	protected String joinValues(final String... values)
 	{
 		return Strings.join(FormComponent.VALUE_SEPARATOR, values);
@@ -255,18 +259,19 @@ public class CookieUtils
 
 		try
 		{
-			Cookie cookie = getWebRequest().getCookie(key);
+			WebRequest webRequest = getWebRequest();
+			Cookie cookie = webRequest.getCookie(key);
 			if (log.isDebugEnabled())
 			{
 				if (cookie != null)
 				{
 					log.debug("Found Cookie with name=" + key + " and request URI=" +
-						getWebRequest().getUrl().toString());
+							webRequest.getUrl().toString());
 				}
 				else
 				{
 					log.debug("Unable to find Cookie with name=" + key + " and request URI=" +
-						getWebRequest().getUrl().toString());
+							webRequest.getUrl().toString());
 				}
 			}