roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r1590462 - in /roller/branches/rome2/app/src/main: java/org/apache/roller/planet/business/updater/ java/org/apache/roller/planet/config/ java/org/apache/roller/weblogger/planet/ui/ java/org/apache/roller/weblogger/ui/rendering/servlets/ res...
Date Sun, 27 Apr 2014 19:19:00 GMT
Author: snoopdave
Date: Sun Apr 27 19:18:59 2014
New Revision: 1590462

URL: http://svn.apache.org/r1590462
Log:
Fix the badly broken Planet configuration page.

Added:
    roller/branches/rome2/app/src/main/java/org/apache/roller/planet/config/
    roller/branches/rome2/app/src/main/java/org/apache/roller/planet/config/PlanetRuntimeConfig.java
      - copied, changed from r1554688, roller/branches/roller_5.0/planet-business/src/main/java/org/apache/roller/planet/config/PlanetRuntimeConfig.java
Modified:
    roller/branches/rome2/app/src/main/java/org/apache/roller/planet/business/updater/SingleThreadedFeedUpdater.java
    roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetConfig.java
    roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java
    roller/branches/rome2/app/src/main/resources/org/apache/roller/planet/config/planetRuntimeConfigDefs.xml

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/planet/business/updater/SingleThreadedFeedUpdater.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/planet/business/updater/SingleThreadedFeedUpdater.java?rev=1590462&r1=1590461&r2=1590462&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/planet/business/updater/SingleThreadedFeedUpdater.java
(original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/planet/business/updater/SingleThreadedFeedUpdater.java
Sun Apr 27 19:18:59 2014
@@ -219,8 +219,8 @@ public class SingleThreadedFeedUpdater i
     
     // upate proxy settings for jvm based on planet configuration
     private void updateProxySettings() {
-        String proxyHost = WebloggerRuntimeConfig.getProperty("site.proxyhost");
-        int proxyPort = WebloggerRuntimeConfig.getIntProperty("site.proxyport");
+        String proxyHost = WebloggerRuntimeConfig.getProperty("planet.site.proxyhost");
+        int proxyPort = WebloggerRuntimeConfig.getIntProperty("planet.site.proxyport");
         if (proxyHost != null && proxyPort > 0) {
             System.setProperty("proxySet", "true");
             System.setProperty("http.proxyHost", proxyHost);

Copied: roller/branches/rome2/app/src/main/java/org/apache/roller/planet/config/PlanetRuntimeConfig.java
(from r1554688, roller/branches/roller_5.0/planet-business/src/main/java/org/apache/roller/planet/config/PlanetRuntimeConfig.java)
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/planet/config/PlanetRuntimeConfig.java?p2=roller/branches/rome2/app/src/main/java/org/apache/roller/planet/config/PlanetRuntimeConfig.java&p1=roller/branches/roller_5.0/planet-business/src/main/java/org/apache/roller/planet/config/PlanetRuntimeConfig.java&r1=1554688&r2=1590462&rev=1590462&view=diff
==============================================================================
--- roller/branches/roller_5.0/planet-business/src/main/java/org/apache/roller/planet/config/PlanetRuntimeConfig.java
(original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/planet/config/PlanetRuntimeConfig.java
Sun Apr 27 19:18:59 2014
@@ -23,19 +23,15 @@ import java.io.InputStreamReader;
 import java.io.StringWriter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.planet.business.PlanetFactory;
-import org.apache.roller.planet.business.PropertiesManager;
-import org.apache.roller.planet.config.runtime.RuntimeConfigDefs;
-import org.apache.roller.planet.config.runtime.RuntimeConfigDefsParser;
+import org.apache.roller.weblogger.business.PropertiesManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.config.runtime.RuntimeConfigDefs;
+import org.apache.roller.weblogger.config.runtime.RuntimeConfigDefsParser;
+import org.apache.roller.weblogger.planet.ui.PlanetConfig;
 
 
 /**
- * This class acts as a convenience gateway for getting property values
- * via the PropertiesManager.  We do this because most calls to the
- * PropertiesManager are just to get the value of a specific property and
- * thus the caller doesn't need the full RollerPropertyData object.
- *
- * We also provide some methods for converting to different data types.
+ * Planet specific runtime properties.
  */
 public class PlanetRuntimeConfig {
     
@@ -62,7 +58,7 @@ public class PlanetRuntimeConfig {
         String value = null;
         
         try {
-            PropertiesManager pmgr = PlanetFactory.getPlanet().getPropertiesManager();
+            PropertiesManager pmgr = WebloggerFactory.getWeblogger().getPropertiesManager();
             value = pmgr.getProperty(name).getValue();
         } catch(Exception e) {
             log.warn("Trouble accessing property: "+name, e);

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetConfig.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetConfig.java?rev=1590462&r1=1590461&r2=1590462&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetConfig.java
(original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/planet/ui/PlanetConfig.java
Sun Apr 27 19:18:59 2014
@@ -24,10 +24,12 @@ import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
+import org.apache.roller.planet.config.PlanetRuntimeConfig;
 import org.apache.roller.weblogger.business.PropertiesManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.config.runtime.ConfigDef;
+import org.apache.roller.weblogger.config.runtime.DisplayGroup;
+import org.apache.roller.weblogger.config.runtime.PropertyDef;
 import org.apache.roller.weblogger.config.runtime.RuntimeConfigDefs;
 import org.apache.roller.weblogger.pojos.GlobalPermission;
 import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
@@ -77,12 +79,14 @@ public class PlanetConfig extends Planet
             // just grab our properties map
             PropertiesManager pMgr = WebloggerFactory.getWeblogger().getPropertiesManager();
             setProperties(pMgr.getProperties());
+
         } catch (RollerException ex) {
             log.error("Error loading planet properties");
         }
         
         // set config def used to draw the view
-        RuntimeConfigDefs defs = WebloggerRuntimeConfig.getRuntimeConfigDefs();
+        RuntimeConfigDefs defs = PlanetRuntimeConfig.getRuntimeConfigDefs();
+
         List<ConfigDef> configDefs = defs.getConfigDefs();
         for (ConfigDef configDef : configDefs) {
             if("global-properties".equals(configDef.getName())) {
@@ -100,38 +104,56 @@ public class PlanetConfig extends Planet
     public String save() {
         
         try {
-            // only set values for properties that are already defined
-            RuntimeConfigProperty updProp;
             String incomingProp = null;
-            for (String propName : getProperties().keySet()) {
-                log.debug("Checking property ["+propName+"]");
-                
-                updProp = getProperties().get(propName);
-                String[] propValues = (String[]) getParameters().get(updProp.getName());
-                if(propValues != null && propValues.length > 0) {
-                    // we don't deal with multi-valued props
-                    incomingProp = propValues[0];
-                }
-                
-                // some special treatment for booleans
-                // this is a bit hacky since we are assuming that any prop
-                // with a value of "true" or "false" is meant to be a boolean
-                // it may not always be the case, but we should be okay for now
-                // below null check needed w/Oracle
-                if( updProp.getValue() != null
-                        && (updProp.getValue().equals("true") || updProp.getValue().equals("false")))
{
-                    
-                    incomingProp = (incomingProp == null || !incomingProp.equals("on")) ?
"false" : "true";
-                }
-                
-                // only work on props that were submitted with the request
-                if(incomingProp != null) {
-                    log.debug("Setting new value for ["+propName+"]");
-                    
-                    updProp.setValue(incomingProp.trim());
+
+
+            // only set values for properties that are already defined
+            RuntimeConfigDefs defs = PlanetRuntimeConfig.getRuntimeConfigDefs();
+            for ( ConfigDef configDef : defs.getConfigDefs()) {
+                for  ( DisplayGroup displayGroup : configDef.getDisplayGroups() ) {
+                    for ( PropertyDef propertyDef : displayGroup.getPropertyDefs() ) {
+
+                        String propName = propertyDef.getName();
+
+                        log.debug("Checking property [" + propName + "]");
+
+                        RuntimeConfigProperty updProp = getProperties().get(propName);
+
+                        if ( updProp == null ) {
+                            updProp = new RuntimeConfigProperty(propName, "");
+                            getProperties().put( propName, updProp);
+                        }
+
+                        String[] propValues = (String[]) getParameters().get(updProp.getName());
+                        if (propValues != null && propValues.length > 0) {
+                            // we don't deal with multi-valued props
+                            incomingProp = propValues[0];
+                        }
+
+                        // some special treatment for booleans
+                        // this is a bit hacky since we are assuming that any prop
+                        // with a value of "true" or "false" is meant to be a boolean
+                        // it may not always be the case, but we should be okay for now
+                        // below null check needed against Oracle DB
+
+                        if (updProp.getValue() != null && (updProp.getValue().equals("true")

+                                || updProp.getValue().equals("false"))) {
+
+                            incomingProp = (incomingProp == null 
+                                || !incomingProp.equals("on")) ? "false" : "true";
+                        }
+
+                        // only work on props that were submitted with the request
+                        if (incomingProp != null) {
+                            log.debug("Setting new value for [" + propName + "]");
+
+                            updProp.setValue(incomingProp.trim());
+                        }
+
+                    }
                 }
             }
-            
+
             // save it
             PropertiesManager pMgr = WebloggerFactory.getWeblogger().getPropertiesManager();
             pMgr.saveProperties(this.properties);

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java?rev=1590462&r1=1590461&r2=1590462&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java
(original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java
Sun Apr 27 19:18:59 2014
@@ -34,6 +34,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.planet.business.PlanetManager;
+import org.apache.roller.planet.config.PlanetRuntimeConfig;
 import org.apache.roller.planet.pojos.Planet;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.pojos.StaticTemplate;
@@ -128,6 +129,7 @@ public class PlanetFeedServlet extends H
         // looks like we need to render content
         HashMap<String, Object> model = new HashMap<String, Object>();
         try {
+
             // populate the rendering model
             if (request.getParameter("group") != null) {
                 Planet planetObject = planet.getWeblogger("default");
@@ -136,29 +138,34 @@ public class PlanetFeedServlet extends H
                         planet.getGroup(planetObject,
                                 request.getParameter("group")));
             }
+
             model.put("planet", planet);
             model.put("date", new Date());
             model.put("utils", new UtilitiesModel());
+            model.put("lastModified", lastModified);
+
             model.put("siteName",
-                    WebloggerRuntimeConfig.getProperty("site.name"));
+                    PlanetRuntimeConfig.getProperty("planet.site.name"));
+
             model.put("siteDescription",
-                    WebloggerRuntimeConfig.getProperty("site.description"));
-            model.put("lastModified", lastModified);
+                    PlanetRuntimeConfig.getProperty("planet.site.description"));
+
+
             if (StringUtils.isNotEmpty(WebloggerRuntimeConfig
-                    .getProperty("site.absoluteurl"))) {
+                    .getProperty("planet.site.absoluteurl"))) {
                 model.put("absoluteSite",
-                        WebloggerRuntimeConfig.getProperty("site.absoluteurl"));
+                        PlanetRuntimeConfig.getProperty("planet.site.absoluteurl"));
             } else {
                 model.put("absoluteSite",
                         WebloggerRuntimeConfig.getAbsoluteContextURL());
             }
-            model.put(
-                    "feedStyle",
-                    WebloggerRuntimeConfig
-                            .getBooleanProperty("site.newsfeeds.styledFeeds"));
+
+            model.put("feedStyle", WebloggerRuntimeConfig
+                    .getBooleanProperty("site.newsfeeds.styledFeeds"));
 
             int numEntries = WebloggerRuntimeConfig
                     .getIntProperty("site.newsfeeds.defaultEntries");
+
             int entryCount = numEntries;
             String sCount = request.getParameter("count");
             if (sCount != null) {

Modified: roller/branches/rome2/app/src/main/resources/org/apache/roller/planet/config/planetRuntimeConfigDefs.xml
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/resources/org/apache/roller/planet/config/planetRuntimeConfigDefs.xml?rev=1590462&r1=1590461&r2=1590462&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/resources/org/apache/roller/planet/config/planetRuntimeConfigDefs.xml
(original)
+++ roller/branches/rome2/app/src/main/resources/org/apache/roller/planet/config/planetRuntimeConfigDefs.xml
Sun Apr 27 19:18:59 2014
@@ -48,31 +48,31 @@
    <!-- Site Settings Group -->
    <display-group name="siteSettings" key="ConfigForm.siteSettings" >
        
-       <property-def  name="site.name"  key="ConfigForm.title">
+       <property-def  name="planet.site.name"  key="ConfigForm.title">
            <type>string</type>
            <default-value>Roller Planet</default-value>
        </property-def>
-       <property-def  name="site.description"  key="ConfigForm.description">
+       <property-def  name="planet.site.description"  key="ConfigForm.description">
            <type>string</type>
            <default-value>A default install of the Roller Planet open source aggregation
server</default-value>
        </property-def>
-       <property-def  name="site.adminname"  key="ConfigForm.adminName">
+       <property-def  name="planet.site.adminname"  key="ConfigForm.adminName">
            <type>string</type>
            <default-value></default-value>
        </property-def>
-       <property-def  name="site.adminemail"  key="ConfigForm.adminEmail">
+       <property-def  name="planet.site.adminemail"  key="ConfigForm.adminEmail">
            <type>string</type>
            <default-value></default-value>
        </property-def>
-       <property-def  name="site.absoluteurl"  key="ConfigForm.absoluteUrl">
+       <property-def  name="planet.site.absoluteurl"  key="ConfigForm.absoluteUrl">
            <type>string</type>
            <default-value></default-value>
        </property-def>
-       <property-def  name="site.proxyhost"  key="ConfigForm.proxyHost">
+       <property-def  name="planet.site.proxyhost"  key="ConfigForm.proxyHost">
            <type>string</type>
            <default-value></default-value>
        </property-def>
-       <property-def  name="site.proxyport"  key="ConfigForm.proxyPort">
+       <property-def  name="planet.site.proxyport"  key="ConfigForm.proxyPort">
            <type>string</type>
            <default-value>0</default-value>
        </property-def>



Mime
View raw message