svn commit: r1025857 - in /lenya/trunk/org.apache.lenya.core.api/src: main/java/org/apache/lenya/cms/publication/URLInformation.java test/java/org/apache/lenya/cms/publication/ test/java/org/apache/lenya/cms/publication/URLInformationTest.java
[email protected] Thu, 21 Oct 2010 07:02:14 -0000
| Newsgroups | gmane.comp.cms.lenya.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: florent
Date: Thu Oct 21 07:02:14 2010
New Revision: 1025857
URL: http://svn.apache.org/viewvc?rev=1025857&view=rev
Log:
- Begin to change URLInformation in order to have a simple class that always deal with information from url. All 'local url process' (like session.getURL(),... etc) have to be remove
- begin to implement the test case, have to solve the build of the test spring context (see notes inside)
Added:
lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/publication/
lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/publication/URLInformationTest.java
Modified:
lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/URLInformation.java
Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/URLInformation.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/URLInformation.java?rev=1025857&r1=1025856&r2=1025857&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/URLInformation.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/publication/URLInformation.java Thu Oct 21 07:02:14 2010
@@ -20,6 +20,12 @@
package org.apache.lenya.cms.publication;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
/**
* This class resolves all Lenya-specific information from a webapp URL.
*/
@@ -32,6 +38,35 @@ public class URLInformation {
private String url;
+ public URLInformation(){
+ String webappUrl = getCurrentURI();
+ setSourceURL(webappUrl);
+ }
+ /**
+ * Ctor.
+ * @param webappUrl A webapp URL (without context prefix).
+ */
+ public URLInformation(String webappUrl) {
+ setSourceURL(webappUrl);
+ }
+
+ private String getCurrentURI(){
+ String currentURI = "";
+ RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
+ if (requestAttributes instanceof ServletRequestAttributes) {
+ HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
+ currentURI = request.getRequestURI(); // ==> /default/authoring/
+ }
+ return currentURI;
+ }
+
+ private void setSourceURL(String webappUrl){
+ if (!webappUrl.startsWith("/")) {
+ throw new RuntimeException("The URL [" + webappUrl + "] doesn't start with a slash!");
+ }
+ this.url = webappUrl.substring(1);
+ }
+
/**
* Returns the area (without the "webdav" prefix).
* @return A string.
@@ -108,16 +143,5 @@ public class URLInformation {
return step;
}
- /**
- * Ctor.
- * @param webappUrl A webapp URL (without context prefix).
- */
- public URLInformation(String webappUrl) {
-
- if (!webappUrl.startsWith("/")) {
- throw new RuntimeException("The URL [" + webappUrl + "] doesn't start with a slash!");
- }
-
- this.url = webappUrl.substring(1);
- }
+
}
Added: lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/publication/URLInformationTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/publication/URLInformationTest.java?rev=1025857&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/publication/URLInformationTest.java (added)
+++ lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/publication/URLInformationTest.java Thu Oct 21 07:02:14 2010
@@ -0,0 +1,19 @@
+package org.apache.lenya.cms.publication;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class URLInformationTest {
+
+ @Ignore("First draft for mock the spring session") @Test
+ public void testSpringSessionSetUp() throws Exception{
+ /**
+ * see this thread : http://forum.springsource.org/archive/index.php/t-50722.html
+ * and specially the post of pbdavey ; May 28th, 2008, 03:10 PM
+ *
+ * This issue is reported here : https://jira.springframework.org/browse/SPR-4588
+ *
+ */
+
+ }
+}