Author: ate
Date: Wed Aug 29 13:44:42 2012
New Revision: 1378551

URL: http://svn.apache.org/viewvc?rev=1378551&view=rev
Log:
RAVE-701: enable simple filesystem based url/page mapping and definition

Added:
    rave/sandbox/content-services/demo-portal/src/main/resources/url-mapping.xml
      - copied, changed from r1377684, 
rave/sandbox/content-services/rave-jcr-integration/page-configuration/src/main/resources/example_url_mapping.xml
    
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/url-configuration.xml
      - copied, changed from r1377684, 
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/url-configuration.xml
Removed:
    
rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/jackrabbit/
    
rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/config/
    
rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/servlet/
    
rave/sandbox/content-services/rave-jcr-integration/page-configuration/src/test/java/org/apache/rave/jcr/config/url/
    
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/page-configuration.xml
    
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/url-configuration.xml
    
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/
Modified:
    
rave/sandbox/content-services/demo-portal/src/main/resources/page-configuration.xml
    
rave/sandbox/content-services/demo-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml
    rave/sandbox/content-services/rave-jcr-console/pom.xml
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java
    
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-configuration.xml

Modified: 
rave/sandbox/content-services/demo-portal/src/main/resources/page-configuration.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/demo-portal/src/main/resources/page-configuration.xml?rev=1378551&r1=1378550&r2=1378551&view=diff
==============================================================================
--- 
rave/sandbox/content-services/demo-portal/src/main/resources/page-configuration.xml
 (original)
+++ 
rave/sandbox/content-services/demo-portal/src/main/resources/page-configuration.xml
 Wed Aug 29 13:44:42 2012
@@ -19,13 +19,13 @@
   -->
 <configuration name="default">
 
-  <page-definition name="myPage" path="/mypage2" description="My Page" 
displayname="My page" 
controller="org.apache.rave.portal.web.hmvc.example.MyPageController">
+  <page-definition name="myPage3" description="My Page" displayname="My page" 
controller="org.apache.rave.portal.web.hmvc.example.MyPageController">
     <page-fragment name="head" 
controller="org.apache.rave.portal.web.hmvc.example.MyHeaderController"/>
     <page-fragment name="body" 
controller="org.apache.rave.portal.web.hmvc.example.MyContentController"/>
     <page-fragment name="footer" 
controller="org.apache.rave.portal.web.hmvc.example.MyFooterController"/>
   </page-definition>
 
-  <page-definition name="userPage" path="/page" 
controller="org.apache.rave.portal.web.hmvc.controller.UserPageController">
+  <page-definition name="myPage4" 
controller="org.apache.rave.portal.web.hmvc.controller.UserPageController">
     <page-fragment name="header" 
controller="org.apache.rave.portal.web.hmvc.controller.PageHeaderController"/>
     <page-fragment name="body" 
controller="org.apache.rave.portal.web.hmvc.controller.PageBodyController">
       <page-fragment name="tabs" 
controller="org.apache.rave.portal.web.hmvc.controller.PageTabsController"/>

Copied: 
rave/sandbox/content-services/demo-portal/src/main/resources/url-mapping.xml 
(from r1377684, 
rave/sandbox/content-services/rave-jcr-integration/page-configuration/src/main/resources/example_url_mapping.xml)
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/demo-portal/src/main/resources/url-mapping.xml?p2=rave/sandbox/content-services/demo-portal/src/main/resources/url-mapping.xml&p1=rave/sandbox/content-services/rave-jcr-integration/page-configuration/src/main/resources/example_url_mapping.xml&r1=1377684&r2=1378551&rev=1378551&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-jcr-integration/page-configuration/src/main/resources/example_url_mapping.xml
 (original)
+++ 
rave/sandbox/content-services/demo-portal/src/main/resources/url-mapping.xml 
Wed Aug 29 13:44:42 2012
@@ -18,18 +18,6 @@
   under the License.
   -->
 <url-configuration name="default">
-  <url-mapping url="/login" page="loginPage">
-    <url-mapping url="loginPage/header"/>
-    <url-mapping url="loginPage/footer"/>
-  </url-mapping>
-  <url-mapping url="/admin" page="adminPage"/>
-  <url-mapping url="/user" page="userAdminPage">
-    <url-mapping url="admin">
-      <url-mapping url="login" page="loginPage">
-        <url-mapping url="userAdminPage/footer"/>
-      </url-mapping>
-      <url-mapping url="add" page="userAdminPage"/>
-      <url-mapping url="delete" page="userAdminPage"/>
-    </url-mapping>
-  </url-mapping>
+  <url-mapping url="/mypage3" page="myPage3"/>
+  <url-mapping url="/mypage4" page="myPage4"/>
 </url-configuration>

Modified: 
rave/sandbox/content-services/demo-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/demo-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml?rev=1378551&r1=1378550&r2=1378551&view=diff
==============================================================================
--- 
rave/sandbox/content-services/demo-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml
 (original)
+++ 
rave/sandbox/content-services/demo-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml
 Wed Aug 29 13:44:42 2012
@@ -162,11 +162,15 @@
   <!-- JCR LOADING -->
   <bean name="hmvcHandlerMappingByConfig" 
class="org.apache.rave.portal.web.hmvc.HmvcHandlerMethodMappingByConfig" 
depends-on="repositoryBootstrap" destroy-method="shutdown">
     <property name="order" value="-1"/>
+    <property name="configManager" ref="fileConfigurationManager"/>
+<!--
     <property name="configurationName" value="myConfiguration"/>
     <property name="configurationPath" value="/raveconfig"/>
-    <property name="configManager" ref="fileConfigurationManager"/>
     <property name="credentials" ref="jcrCredentials"/>
     <property name="lazyRepositoryFactory" ref="lazyRepositoryFactory"/>
+-->
+    <property name="configurationPath" 
value="classpath:page-configuration.xml"/>
+    <property name="urlMappingsPath" value="classpath:url-mapping.xml"/>
   </bean>
 
   <bean id="fileConfigurationManager" 
class="org.apache.rave.jcr.config.FileConfigManager"/>

Modified: rave/sandbox/content-services/rave-jcr-console/pom.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-console/pom.xml?rev=1378551&r1=1378550&r2=1378551&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-console/pom.xml (original)
+++ rave/sandbox/content-services/rave-jcr-console/pom.xml Wed Aug 29 13:44:42 
2012
@@ -79,20 +79,14 @@
 
     <!-- adding slf4j and log4j dependencies to be bundled (not provided) -->
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
-    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
+      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>jcl-over-slf4j</artifactId>
+      <scope>compile</scope>
     </dependency>
 
   </dependencies>

Modified: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java?rev=1378551&r1=1378550&r2=1378551&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java
 Wed Aug 29 13:44:42 2012
@@ -38,6 +38,7 @@ import org.apache.rave.jcr.config.model.
 import org.apache.rave.jcr.config.model.api.PageDefinition;
 import org.apache.rave.jcr.config.model.api.PageFragment;
 import org.apache.rave.jcr.config.model.api.UrlConfiguration;
+import org.apache.rave.jcr.config.model.api.UrlMapping;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.annotation.AnnotationUtils;
@@ -92,7 +93,7 @@ public class HmvcHandlerMethodMappingByC
             final PageConfiguration configuration = 
configManager.loadConfiguration(configurationPath);
             final UrlConfiguration urlConfig = 
configManager.loadUrlConfig(urlMappingsPath, configuration);
             // TODO use urlConfig
-            processConfiguration(configuration);
+            processConfiguration(urlConfig);
         }
     }
 
@@ -106,8 +107,8 @@ public class HmvcHandlerMethodMappingByC
             final PageConfiguration configuration = 
configManager.loadConfiguration(configurationName);
             log.info("configuration {}", configuration);
             // TODO use urlConfig
-//            final UrlConfiguration urlConfig = 
configManager.loadUrlConfig(urlMappingsPath, configuration);
-            processConfiguration(configuration);
+            final UrlConfiguration urlConfig = 
configManager.loadUrlConfig(urlMappingsPath, configuration);
+            processConfiguration(urlConfig);
         } catch (RepositoryException e) {
             log.error("Error obtaining session", e);
         } finally {
@@ -127,10 +128,10 @@ public class HmvcHandlerMethodMappingByC
         repositoryFactory.removeListener(this);
     }
 
-    private void processConfiguration(PageConfiguration configuration) {
-        final List<PageDefinition> pageDefinitions = 
configuration.getPageDefinitions();
+    private void processConfiguration(UrlConfiguration configuration) {
 
-        for (PageDefinition pageDefinition : pageDefinitions) {
+        for (UrlMapping urlMapping : configuration.getMappings()) {
+            PageDefinition pageDefinition = urlMapping.getPageDefinition();
             final String controller = pageDefinition.getController();
             log.info("Processing controller [ {} ]", controller);
             // TODO: handle exception, class not found etc.
@@ -139,7 +140,7 @@ public class HmvcHandlerMethodMappingByC
                 Method method = getRenderMethod(controllerClass);
                 if (method != null) {
                     RequestMapping annotation = 
AnnotationUtils.findAnnotation(method, RequestMapping.class);
-                    RequestMappingInfo mappingInfo = 
createMappingInfo(annotation, pageDefinition);
+                    RequestMappingInfo mappingInfo = 
createMappingInfo(annotation, urlMapping.getUrl());
                     try {
                         Object handler = 
getApplicationContext().getBean(controllerClass);
 //                        Object handler = controllerClass.newInstance();
@@ -212,8 +213,8 @@ public class HmvcHandlerMethodMappingByC
     }
 
 
-    private RequestMappingInfo createMappingInfo(RequestMapping annotation, 
PageFragment pageDefinition) {
-        final String[] patterns = {pageDefinition.getPath()};
+    private RequestMappingInfo createMappingInfo(RequestMapping annotation, 
String path) {
+        final String[] patterns = {path};
         log.info("Creating mapping for patterns:[{}]", patterns);
         final PatternsRequestCondition requestCondition = new 
PatternsRequestCondition(
                 patterns, getUrlPathHelper(), getPathMatcher(), 
useSuffixPatternMatch(), useTrailingSlashMatch());
@@ -255,7 +256,9 @@ public class HmvcHandlerMethodMappingByC
     @Override
     protected HandlerMethod getHandlerInternal(HttpServletRequest request) 
throws Exception {
         // force check repository available
-        repositoryFactory.getRepository();
+        if (repositoryFactory != null) {
+            repositoryFactory.getRepository();
+        }
         return super.getHandlerInternal(request);
     }
 }
\ No newline at end of file

Modified: 
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-configuration.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-configuration.xml?rev=1378551&r1=1378550&r2=1378551&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-configuration.xml
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-configuration.xml
 Wed Aug 29 13:44:42 2012
@@ -19,10 +19,10 @@
   -->
 <configuration name="default">
 
-  <page-definition name="myPage" path="/mypage2" description="My Page" 
displayname="My page" 
controller="org.apache.rave.portal.web.hmvc.example.MyPageController">
-    <page-fragment name="head" path="myHeader" 
controller="org.apache.rave.portal.web.hmvc.example.MyHeaderController" 
viewname="hmvc/override/myheader"/>
-    <page-fragment name="body" path="myBody" 
controller="org.apache.rave.portal.web.hmvc.example.MyContentController"/>
-    <page-fragment name="footer" path="myFooter" 
controller="org.apache.rave.portal.web.hmvc.example.MyFooterController"/>
+  <page-definition name="myPage" description="My Page" displayname="My page" 
controller="org.apache.rave.portal.web.hmvc.example.MyPageController">
+    <page-fragment name="head" 
controller="org.apache.rave.portal.web.hmvc.example.MyHeaderController" 
viewname="hmvc/override/myheader"/>
+    <page-fragment name="body" 
controller="org.apache.rave.portal.web.hmvc.example.MyContentController"/>
+    <page-fragment name="footer" 
controller="org.apache.rave.portal.web.hmvc.example.MyFooterController"/>
   </page-definition>
 
 </configuration>

Copied: 
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/url-configuration.xml
 (from r1377684, 
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/url-configuration.xml)
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/resources/url-configuration.xml?p2=rave/sandbox/content-services/rave-web-hmvc/src/test/resources/url-configuration.xml&p1=rave/sandbox/content-services/rave-web-hmvc/src/main/resources/url-configuration.xml&r1=1377684&r2=1378551&rev=1378551&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/url-configuration.xml
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/url-configuration.xml
 Wed Aug 29 13:44:42 2012
@@ -25,7 +25,7 @@
 </page-definition>
 -->
 <url-configuration name="default">
-  <url-mapping url="/myPage2" page="myPage">
+  <url-mapping url="/mypage2" page="myPage">
     <url-mapping url="myHeader" page="head"/>
     <url-mapping url="myBody" page="body"/>
     <url-mapping url="myFooter" page="footer"/>


Reply via email to