Author: ate
Date: Tue Sep 11 21:05:20 2012
New Revision: 1383609

URL: http://svn.apache.org/viewvc?rev=1383609&view=rev
Log:
RAVE-696: 
- fixing and cleaning up JCR pages and routes model and mapping
- use JCR pages and routes configuration again
- fixing reload on change check in both JcrPagesConfigManager and 
XmlPagesConfigManager

Modified:
    
rave/sandbox/content-services/demo-portal/src/main/resources/page-config.json
    
rave/sandbox/content-services/demo-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java
    rave/sandbox/content-services/rave-web-jcr/pom.xml
    
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageDefinitions.java
    
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageFragment.java
    
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPagesConfigManager.java
    
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoute.java
    
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoutes.java

Modified: 
rave/sandbox/content-services/demo-portal/src/main/resources/page-config.json
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/demo-portal/src/main/resources/page-config.json?rev=1383609&r1=1383608&r2=1383609&view=diff
==============================================================================
--- 
rave/sandbox/content-services/demo-portal/src/main/resources/page-config.json 
(original)
+++ 
rave/sandbox/content-services/demo-portal/src/main/resources/page-config.json 
Tue Sep 11 21:05:20 2012
@@ -1,44 +1,61 @@
 {
-    "myRoutes":{
+    "routes":{
         "jcr:primaryType":"raveconfig:routes",
-        "name":"myRoutes",
+        "name":"routes",
         "route1":{
             "jcr:primaryType":"raveconfig:route",
             "name":"route1",
-            "path":"/mypage1",
-            "target":"/mypage",
-            "action": "action1"
+            "path":"/home",
+            "target":"userPage",
+            "action": "defaultPage"
         },
         "route2":{
             "jcr:primaryType":"raveconfig:route",
             "name":"route2",
-            "path":"/mypage2",
-            "target":"/mypage",
-            "action": "action2"
+            "path":"/page",
+            "target":"userPage",
+            "action": "defaultPage"
+        },
+        "route3":{
+            "jcr:primaryType":"raveconfig:route",
+            "name":"route3",
+            "path":"/page/{pageId}",
+            "target":"userPage"
         }
     },
-    "myPages":{
+    "pages":{
         "jcr:primaryType":"raveconfig:pagedefinitions",
-        "name":"myPages",
-        "myPage":{
+        "name":"pages",
+        "userPage":{
             "jcr:primaryType":"raveconfig:pagefragment",
-            "name":"myPage",
-            "description":"Simple page",
-            
"controller":"org.apache.rave.unittest.NonExistingMyPageController",
-            "head":{
+            "name":"userPage",
+            "viewName":"pages/userpage/page",
+            
"controller":"org.apache.rave.portal.web.mvc.controller.UserPageController",
+            "header":{
                 "jcr:primaryType":"raveconfig:pagefragment",
-                "name":"head",
-                
"controller":"org.apache.rave.unittest.NonExistingMyHeaderController"
+                "name":"header",
+                "viewName":"pages/userpage/page-header",
+                
"controller":"org.apache.rave.portal.web.mvc.controller.PageHeaderController"
             },
             "body":{
                 "jcr:primaryType":"raveconfig:pagefragment",
                 "name":"body",
-                
"controller":"org.apache.rave.unittest.NonExistingMyContentController"
+                "viewName":"pages/userpage/page-body",
+                "tabs":{
+                    "jcr:primaryType":"raveconfig:pagefragment",
+                    "name":"tabs",
+                    "viewName":"pages/userpage/page-body"
+                },
+                "content":{
+                    "jcr:primaryType":"raveconfig:pagefragment",
+                    "name":"content",
+                    "viewName":"pages/userpage/page-content"
+                }
             },
             "footer":{
                 "jcr:primaryType":"raveconfig:pagefragment",
                 "name":"footer",
-                
"controller":"org.apache.rave.unittest.NonExistingMyFooterController"
+                "viewName":"pages/footer"
             }
         }
     }

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=1383609&r1=1383608&r2=1383609&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
 Tue Sep 11 21:05:20 2012
@@ -150,13 +150,15 @@
   <!-- JCR|File based LOADING -->
   <bean name="nestedHandlerMethodHandlerMapping" 
class="org.apache.rave.portal.web.mvc.NestedHandlerMethodHandlerMapping">
     <property name="order" value="-1"/>
-    <property name="configManager" ref="xmlPagesConfigManager"/>
-  <!--
-      <property name="configurationName" value="myConfiguration"/>
-      <property name="pageDefinitionsPath" value="/raveconfig"/>
-      <property name="credentials" ref="jcrCredentials"/>
-      <property name="lazyRepositoryFactory" ref="lazyRepositoryFactory"/>
-  -->
+    <property name="configManager" ref="jcrPagesConfigManager"/>
+  </bean>
+
+  <bean id="jcrPagesConfigManager" 
class="org.apache.rave.portal.web.mvc.config.jcr.JcrPagesConfigManager" 
destroy-method="shutdown">
+    <constructor-arg index="0" ref="lazyRepositoryFactory"/>
+    <constructor-arg index="1" ref="jcrCredentials"/>
+    <constructor-arg index="2" value="/raveconfig/routes"/>
+    <constructor-arg index="3" value="/raveconfig/pages"/>
+    <property name="refreshDelay" value="3000"/>
   </bean>
 
   <bean id="xmlPagesConfigManager" 
class="org.apache.rave.portal.web.mvc.config.xml.XmlPagesConfigManager">

Modified: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java?rev=1383609&r1=1383608&r2=1383609&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java
 Tue Sep 11 21:05:20 2012
@@ -100,7 +100,7 @@ public class XmlPagesConfigManager imple
     }
 
     private boolean checkBuildTime() {
-        if ((lastBuildTime + refreshDelay) >  System.currentTimeMillis()) {
+        if (refreshDelay == 0 || lastBuildTime + refreshDelay <  
System.currentTimeMillis()) {
             if (lastModified() > lastBuildTime) {
                 return true;
             }

Modified: rave/sandbox/content-services/rave-web-jcr/pom.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-jcr/pom.xml?rev=1383609&r1=1383608&r2=1383609&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-jcr/pom.xml (original)
+++ rave/sandbox/content-services/rave-web-jcr/pom.xml Tue Sep 11 21:05:20 2012
@@ -138,6 +138,7 @@
         <configuration>
           <excludes>
             <exclude>**/JcrConfigManagerTest.java</exclude>
+            <exclude>**/resource/*Test.java</exclude>
           </excludes>
         </configuration>
       </plugin>

Modified: 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageDefinitions.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageDefinitions.java?rev=1383609&r1=1383608&r2=1383609&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageDefinitions.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageDefinitions.java
 Tue Sep 11 21:05:20 2012
@@ -21,6 +21,7 @@ package org.apache.rave.portal.web.mvc.c
 
 import java.util.List;
 
+import 
org.apache.jackrabbit.ocm.manager.collectionconverter.impl.NTCollectionConverterImpl;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
@@ -32,21 +33,12 @@ import org.apache.rave.portal.web.mvc.co
 @Node(discriminator = false, jcrType = "raveconfig:pagedefinitions")
 public class JcrPageDefinitions {
 
-
-    @Field(path = true, id = true)
-    private String path;
-
-    @Collection(elementClassName = JcrPageFragment.class, jcrType = 
"raveconfig:pagefragment")
+    @Collection(elementClassName = JcrPageFragment.class, jcrType = 
"raveconfig:pagefragment", collectionConverter = 
NTCollectionConverterImpl.class)
     private List<PageFragment> pageFragments;
 
-    @Field(jcrName = "raveconfig:name", jcrType = "String")
+    @Field
     private String name;
 
-
-    public void initialize() {
-        // TODO implement
-    }
-
     public String getName() {
         return name;
     }
@@ -64,20 +56,11 @@ public class JcrPageDefinitions {
         pageFragments = fragments;
     }
 
-    public String getPath() {
-        return path;
-    }
-
-    public void setPath(String path) {
-        this.path = path;
-    }
-
     @Override
     public String toString() {
         final StringBuilder sb = new StringBuilder();
         sb.append("JcrPageDefinitions");
         sb.append("{name='").append(name).append('\'');
-        sb.append(", path='").append(path).append('\'');
         sb.append('}');
         return sb.toString();
     }

Modified: 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageFragment.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageFragment.java?rev=1383609&r1=1383608&r2=1383609&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageFragment.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPageFragment.java
 Tue Sep 11 21:05:20 2012
@@ -22,6 +22,7 @@ package org.apache.rave.portal.web.mvc.c
 import java.util.ArrayList;
 import java.util.List;
 
+import 
org.apache.jackrabbit.ocm.manager.collectionconverter.impl.NTCollectionConverterImpl;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
@@ -40,35 +41,24 @@ public class JcrPageFragment implements 
     public JcrPageFragment() {
     }
 
-    public JcrPageFragment(String name) {
-        this.name = name;
-    }
-
-    @Field(path = true)
-    private String path;
-
-    @Field(jcrName="abstract", jcrType = "Boolean")
+    @Field(jcrName="abstract", jcrDefaultValue = "false")
     private boolean jcrAbstact;
-    @Field(jcrName="extends", jcrType = "String")
+    @Field(jcrName="extends")
     private String jcrExtends;
-    @Field(jcrType = "String")
+    @Field
     private String controller;
-    @Field(jcrType = "String")
+    @Field
     private String viewName;
 
-    @Field(jcrType = "String")
+    @Field
     private String description;
 
-    @Field(jcrType = "String", id=true)
+    @Field
     private String name;
 
-    @Collection(elementClassName = JcrPageFragment.class, jcrType = 
"raveconfig:pagefragment")
+    @Collection(elementClassName = JcrPageFragment.class, jcrType = 
"raveconfig:pagefragment", collectionConverter = 
NTCollectionConverterImpl.class)
     private List<PageFragment> children;
 
-    public String getPath() {
-        return path;
-    }
-
     @Override
     public String getViewName() {
         return viewName;
@@ -78,10 +68,6 @@ public class JcrPageFragment implements 
         this.viewName = viewName;
     }
 
-    public void setPath(String path) {
-        this.path = path;
-    }
-
     @Override
     public String getName() {
         return name;
@@ -164,7 +150,6 @@ public class JcrPageFragment implements 
     public String toString() {
         final StringBuilder sb = new StringBuilder();
         sb.append("JcrPageFragment");
-        sb.append("{path='").append(path).append('\'');
         sb.append(", extends='").append(jcrExtends).append('\'');
         sb.append(", controller='").append(controller).append('\'');
         sb.append(", name='").append(name).append('\'');

Modified: 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPagesConfigManager.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPagesConfigManager.java?rev=1383609&r1=1383608&r2=1383609&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPagesConfigManager.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrPagesConfigManager.java
 Tue Sep 11 21:05:20 2012
@@ -111,22 +111,22 @@ public class JcrPagesConfigManager imple
     }
 
     private boolean checkBuildTime() {
-        if ((lastBuildTime + refreshDelay) >  System.currentTimeMillis()) {
-            if (lastModified() > lastBuildTime) {
-                return true;
-            }
+        if (refreshDelay == 0 || lastBuildTime + refreshDelay <  
System.currentTimeMillis()) {
+            // for now: always reload after refreshDelay
+            return true;
         }
         return false;
     }
 
     public synchronized void shutdown() {
-//        repositoryFactory.removeListener(this);
+        repositoryFactory.removeListener(this);
     }
 
     protected synchronized void loadConfig() {
         Session session = null;
         config = null;
         try {
+            long buildTime = System.currentTimeMillis();
             session = repository.login(credetials);
             ObjectContentManager ocm = createManager(session);
             JcrRoutes routes = (JcrRoutes) ocm.getObject(JcrRoutes.class, 
routesPath);
@@ -138,7 +138,7 @@ public class JcrPagesConfigManager imple
                 pages.put(pf.getName(), pf);
             }
             config = new PagesConfigImpl(routes.getRoutes(), pages);
-            lastBuildTime = System.currentTimeMillis();
+            lastBuildTime = buildTime;
 
         } catch (RepositoryException e) {
             e.printStackTrace();  //To change body of catch statement use File 
| Settings | File Templates.

Modified: 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoute.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoute.java?rev=1383609&r1=1383608&r2=1383609&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoute.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoute.java
 Tue Sep 11 21:05:20 2012
@@ -21,6 +21,7 @@ package org.apache.rave.portal.web.mvc.c
 
 import java.util.List;
 
+import 
org.apache.jackrabbit.ocm.manager.collectionconverter.impl.NTCollectionConverterImpl;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
@@ -36,19 +37,16 @@ public class JcrRoute implements Route {
 
     private static Logger log = LoggerFactory.getLogger(JcrRoute.class);
 
-    @Field(path = true, id = true)
-    private String jcrNodePath;
-
-    @Field(jcrType = "String")
+    @Field
     private String path;
 
-    @Field(jcrType = "String")
+    @Field
     private String target;
 
-    @Field(jcrType = "String")
+    @Field
     private String action;
 
-    @Collection(elementClassName = JcrRoute.class, jcrType = 
"raveconfig:route", jcrName = "raveconfig:route")
+    @Collection(elementClassName = JcrRoute.class, jcrType = 
"raveconfig:route", collectionConverter = NTCollectionConverterImpl.class)
     private List<Route> children;
 
     @Override

Modified: 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoutes.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoutes.java?rev=1383609&r1=1383608&r2=1383609&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoutes.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-jcr/src/main/java/org/apache/rave/portal/web/mvc/config/jcr/JcrRoutes.java
 Tue Sep 11 21:05:20 2012
@@ -22,6 +22,7 @@ package org.apache.rave.portal.web.mvc.c
 import java.util.ArrayList;
 import java.util.List;
 
+import 
org.apache.jackrabbit.ocm.manager.collectionconverter.impl.NTCollectionConverterImpl;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
@@ -33,13 +34,13 @@ import org.apache.rave.portal.web.mvc.co
 @Node(discriminator = false, jcrType = "raveconfig:routes", jcrMixinTypes = 
"mix:referenceable")
 public class JcrRoutes {
 
-    @Field(path = true, id = true)
+    @Field(path = true)
     private String path;
 
-    @Field(jcrName = "raveconfig:name", jcrType = "String")
+    @Field
     private String name;
 
-    @Collection(elementClassName = JcrRoute.class, jcrType = 
"raveconfig:route")
+    @Collection(elementClassName = JcrRoute.class, jcrType = 
"raveconfig:route", collectionConverter = NTCollectionConverterImpl.class)
     private List<Route> routes;
 
     public JcrRoutes() {


Reply via email to