roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r528288 - in /roller/trunk: metadata/database/tmpls/ src/org/apache/roller/business/utils/ src/org/apache/roller/planet/tasks/ src/org/apache/roller/planet/ui/admin/struts/actions/ src/org/apache/roller/planet/ui/admin/struts/forms/ src/org...
Date Fri, 13 Apr 2007 00:02:03 GMT
Author: agilliland
Date: Thu Apr 12 17:02:00 2007
New Revision: 528288

URL: http://svn.apache.org/viewvc?view=rev&rev=528288
Log:
Fixing up Weblogger and Planet integration some more.  This commit ...

1. updated roller-planet-business.jar used by Weblogger app.

2. cleans up the sql scripts a bit more to include the latest tables from the Planet project.

3. fixes up the initialization process to better handle Planet initialization when Weblogger is starting up.

4. makes some changes for upgrading users to conform to the way the Planet codebase works.  The old planet code allowed for querying a list of entries based on the union of multiple groups, but there is really no reason for that and so it's not allowed in the current Planet code.  In specific, Weblogger used to maintain 2 groups ('all' and 'external') and query for their entries together, but instead those 2 groups have been merged as part of the 4.0 upgrade process now.



Removed:
    roller/trunk/src/org/apache/roller/planet/ui/admin/struts/forms/PlanetSubscriptionFormEx.java
Modified:
    roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm
    roller/trunk/metadata/database/tmpls/createdb.vm
    roller/trunk/src/org/apache/roller/business/utils/UpgradeDatabase.java
    roller/trunk/src/org/apache/roller/planet/tasks/SyncWebsitesTask.java
    roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java
    roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java
    roller/trunk/src/org/apache/roller/planet/ui/admin/struts/forms/PlanetSubscriptionForm.java
    roller/trunk/src/org/apache/roller/ui/core/RollerContext.java
    roller/trunk/tools/roller-planet/roller-planet-business.jar
    roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
    roller/trunk/web/WEB-INF/jsps/admin/PlanetSubscriptions.jsp

Modified: roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm
URL: http://svn.apache.org/viewvc/roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm (original)
+++ roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm Thu Apr 12 17:02:00 2007
@@ -4,6 +4,11 @@
 DON'T RUN THIS, IT'S NOT A DATABASE CREATION SCRIPT!!!
 **#
 
+create table rag_properties (
+    name     varchar(255) not null primary key,
+    value    $db.TEXT_SQL_TYPE
+);
+
 create table rag_planet (
     id              varchar(48) not null primary key,
     handle          varchar(32) not null,
@@ -12,8 +17,18 @@
 );
 alter table rag_planet add constraint ragp_handle_uq unique ( handle );
 
+-- add new planet_id column to planet group table
+#addColumnNull("rag_group" "planet_id" "varchar(48)")
+
+-- upgrade old planet users to work with the new Roller Planet code
+-- all groups must have a planet now, so provide a default planet and
+-- put all existing groups in the new default planet
 insert into rag_planet (id,title,handle) values ('zzz_default_planet_zzz','Default Planet','zzz_default_planet_zzz');
 update rag_group set planet_id='zzz_default_planet_zzz';
+
+-- drop old planet config table
+drop table if exists rag_config;
+
 
 -- new column to support account activation by email
 #addColumnNull("rolleruser" "activationcode" "varchar(48)")

Modified: roller/trunk/metadata/database/tmpls/createdb.vm
URL: http://svn.apache.org/viewvc/roller/trunk/metadata/database/tmpls/createdb.vm?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/metadata/database/tmpls/createdb.vm (original)
+++ roller/trunk/metadata/database/tmpls/createdb.vm Thu Apr 12 17:02:00 2007
@@ -424,45 +424,38 @@
 
 
 
-create table rag_group_subscription (
-    group_id         varchar(48) not null,
-    subscription_id  varchar(48) not null
+create table rag_properties (
+    name     varchar(255) not null primary key,
+    value    $db.TEXT_SQL_TYPE
 );
-create index raggs_gid_idx on rag_group_subscription(group_id); 
-create index raggs_sid_idx on rag_group_subscription(subscription_id); 
 
-create table rag_config (
-    id               varchar(48) not null primary key,
-    default_group_id varchar(48),
-    title            varchar(255) not null,
-    description      varchar(255),
-    site_url         varchar(255),
-    output_dir       varchar(255),
-    cache_dir        varchar(255) not null,
-    template_dir     varchar(255),
-    main_page        varchar(255),
-    admin_name       varchar(255),
-    admin_email      varchar(255) not null,
-    group_page       varchar(255),
-    proxy_host       varchar(255),
-    proxy_port       integer default -1
+
+create table rag_planet (
+    id              varchar(48) not null primary key,
+    handle          varchar(32) not null,
+    title           varchar(255) not null,
+    description     varchar(255)
 );
+alter table rag_planet add constraint ragp_handle_uq unique ( handle );
+
 
 create table rag_group (
     id               varchar(48) not null primary key,
-    handle           varchar(255) not null,
+    planet_id        varchar(48) not null,
+    handle           varchar(32) not null,
     title            varchar(255) not null,
     description      varchar(255),
-    cat_restriction  $db.TEXT_SQL_TYPE,
-    group_page       varchar(255),
     max_page_entries integer default 30,
-    max_feed_entries integer default 30
+    max_feed_entries integer default 30,
+    cat_restriction  $db.TEXT_SQL_TYPE,
+    group_page       varchar(255)
 );
-alter table rag_group add constraint ragg_handle_uq unique ( handle$!db.INDEXSIZE );
+alter table rag_group add constraint ragg_handle_uq unique ( planet_id, handle );
+
 
 create table rag_subscription (
     id               varchar(48) not null primary key,
-    title            varchar(255),
+    title            varchar(255) not null,
     feed_url         varchar(255) not null,
     site_url         varchar(255),
     author           varchar(255),
@@ -472,6 +465,15 @@
 );
 alter table rag_subscription add constraint rags_feed_url_uq unique ( feed_url$!db.INDEXSIZE_LARGE );
 
+
+create table rag_group_subscription (
+    group_id         varchar(48) not null,
+    subscription_id  varchar(48) not null
+);
+create index raggs_gid_idx on rag_group_subscription(group_id); 
+create index raggs_sid_idx on rag_group_subscription(subscription_id); 
+
+
 create table rag_entry (
     id               varchar(48) not null primary key,
     subscription_id  varchar(48) not null,
@@ -485,18 +487,11 @@
     published        $db.TIMESTAMP_SQL_TYPE not null,
     updated          $db.TIMESTAMP_SQL_TYPE    
 );
-create index rage_sid_idx on rag_entry(subscription_id); 
-
-create table rag_planet (
-    id              varchar(48) not null primary key,
-    handle          varchar(32) not null,
-    title           varchar(255) not null,
-    description     varchar(255)
-);
-alter table rag_planet add constraint ragp_handle_uq unique ( handle );
+create index rage_sid_idx on rag_entry(subscription_id);
 
-insert into rag_planet (id,title,handle) values ('zzz_default_planet_zzz','Default Planet','zzz_default_planet_zzz');
-update rag_group set planet_id='zzz_default_planet_zzz';
+-- create a default planet and group
+insert into rag_planet (id, handle, title) values ('zzz_default_planet_zzz', 'default', 'Default Planet');
+insert into rag_group (id, planet_id, handle, title) values ('zzz_all_group_zzz', 'zzz_default_planet_zzz', 'all', 'Default Group');
 
 
 -- *****************************************************

Modified: roller/trunk/src/org/apache/roller/business/utils/UpgradeDatabase.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/business/utils/UpgradeDatabase.java?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/src/org/apache/roller/business/utils/UpgradeDatabase.java (original)
+++ roller/trunk/src/org/apache/roller/business/utils/UpgradeDatabase.java Thu Apr 12 17:02:00 2007
@@ -135,6 +135,10 @@
             UpgradeDatabase.upgradeTo320(con);
             dbversion = 320;
         }
+        if(dbversion < 400) {
+            UpgradeDatabase.upgradeTo400(con);
+            dbversion = 400;
+        }
         
         // make sure the database version is the exact version
         // we are upgrading too.
@@ -650,6 +654,71 @@
         
         // finally, upgrade db version string to 320
         UpgradeDatabase.updateDatabaseVersion(con, 320);
+    }
+    
+    
+    /**
+     * Upgrade database for Roller 4.0.0
+     */
+    private static void upgradeTo400(Connection con) throws RollerException {
+        
+        mLogger.info("Doing upgrade to 400 ...");
+        
+        try {    
+            mLogger.info("Merging planet groups 'all' and 'external'");
+            
+            // Move all subscriptions in the planet group 'external' to group 'all'
+            
+            String allGroupId = null;
+            PreparedStatement selectAllGroupId = con.prepareStatement(
+                "select id from rag_group where handle = 'all'");
+            ResultSet rs = selectAllGroupId.executeQuery();
+            if (rs.next()) {
+                allGroupId = rs.getString(1);
+            }
+            
+            String externalGroupId = null;
+            PreparedStatement selectExternalGroupId = con.prepareStatement(
+                "select id from rag_group where handle = 'external'");            
+            rs = selectExternalGroupId.executeQuery();
+            if (rs.next()) {
+                externalGroupId = rs.getString(1);
+            }
+            
+            // we only need to merge if both of those groups already existed
+            if(allGroupId != null && externalGroupId != null) {
+                PreparedStatement updateGroupSubs = con.prepareStatement(
+                        "update rag_group_subscription set group_id = ? where group_id = ?");
+                updateGroupSubs.clearParameters();
+                updateGroupSubs.setString( 1, allGroupId);
+                updateGroupSubs.setString( 2, externalGroupId);
+                updateGroupSubs.executeUpdate();
+                
+                // we no longer need the group 'external'
+                PreparedStatement deleteExternalGroup = con.prepareStatement(
+                        "delete from rag_group where handle = 'external'");
+                deleteExternalGroup.executeUpdate();
+                
+            // if we only have group 'external' then just rename it to 'all'
+            } else if(allGroupId == null && externalGroupId != null) {
+                
+                // rename 'external' to 'all'
+                PreparedStatement renameExternalGroup = con.prepareStatement(
+                        "update rag_group set handle = 'all' where handle = 'external'");
+                renameExternalGroup.executeUpdate();
+            }
+            
+            if (!con.getAutoCommit()) con.commit();
+           
+            mLogger.info("Planet group 'external' merged into group 'all'.");
+            
+        } catch (SQLException e) {
+            mLogger.error("Problem upgrading database to version 400", e);
+            throw new RollerException("Problem upgrading database to version 400", e);
+        }
+        
+        // finally, upgrade db version string to 400
+        UpgradeDatabase.updateDatabaseVersion(con, 400);
     }
     
     

Modified: roller/trunk/src/org/apache/roller/planet/tasks/SyncWebsitesTask.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/planet/tasks/SyncWebsitesTask.java?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/src/org/apache/roller/planet/tasks/SyncWebsitesTask.java (original)
+++ roller/trunk/src/org/apache/roller/planet/tasks/SyncWebsitesTask.java Thu Apr 12 17:02:00 2007
@@ -190,7 +190,12 @@
             while(subs.hasNext()) {
                 PlanetSubscriptionData sub =
                         (PlanetSubscriptionData) subs.next();
-                if (!liveUserFeeds.contains(sub.getFeedURL())) {
+                
+                // only delete subs from the group if ...
+                // 1. they are local, meaning they use our absolute url
+                // 2. they are no longer listed as a weblog 
+                if (sub.getFeedURL().startsWith(absUrl) && 
+                        !liveUserFeeds.contains(sub.getFeedURL())) {
                     deleteSubs.add(sub);
                 }
             }

Modified: roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java (original)
+++ roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java Thu Apr 12 17:02:00 2007
@@ -60,7 +60,9 @@
     private static Log logger = LogFactory.getLog(PlanetGroupsAction.class);
     
     
-    /** Populate page model and forward to subscription page */
+    /** 
+     * Populate page model and forward to groups page 
+     */
     public ActionForward getGroups(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
@@ -92,7 +94,9 @@
     }
     
     
-    /** Cancel editing, reset form */
+    /** 
+     * Cancel editing, reset form 
+     */
     public ActionForward cancelEditing(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
@@ -116,7 +120,9 @@
     }
     
     
-    /** Delete subscription, reset form  */
+    /** 
+     * Delete group, reset form  
+     */
     public ActionForward deleteGroup(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
@@ -132,8 +138,6 @@
                     PlanetGroupData group = pmgr.getGroup(defaultPlanet, form.getHandle());
                     pmgr.deleteGroup(group);
                     PlanetFactory.getPlanet().flush();
-                    // TODO: why release here?
-                    PlanetFactory.getPlanet().release();
                     
                     form.doReset(mapping, request);
                     
@@ -157,7 +161,9 @@
     }
     
     
-    /** Save subscription, add to "external" group */
+    /** 
+     * Save group 
+     */
     public ActionForward saveGroup(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
@@ -214,7 +220,9 @@
     }
     
     
-    /** Validate posted group */
+    /** 
+     * Validate posted group 
+     */
     private ActionErrors validate(
             PlanetManager planet, PlanetGroupForm form) {
         ActionErrors errors = new ActionErrors();
@@ -225,35 +233,42 @@
             errors.add(null, new ActionError("planetGroups.error.handle"));
         }
         if (form.getHandle() != null &&
-                (form.getHandle().equals("all") || form.getHandle().equals("external"))) {
+                (form.getHandle().equals("all"))) {
             errors.add(null, new ActionError("planetGroups.error.nameReserved"));
         }
         return errors;
     }
     
     
-    /** Page model */
+    /** 
+     * Page model 
+     */
     public class GroupsPageModel extends BasePageModel {
+        
         private List groups = new ArrayList();
         private boolean unconfigured = false;
+        
         public GroupsPageModel(
                 HttpServletRequest request,
                 HttpServletResponse response,
                 ActionMapping mapping) throws RollerException {
+            
             super("planetGroups.pagetitle", request, response, mapping);
-            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            
             PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
             PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
-            PlanetGroupData externalGroup = pmgr.getGroup(defaultPlanet, "external");
             Iterator allgroups = defaultPlanet.getGroups().iterator();
             while (allgroups.hasNext()) {
                 PlanetGroupData agroup = (PlanetGroupData)allgroups.next();
-                if (    !agroup.getHandle().equals("external")
-                && !agroup.getHandle().equals("all")) {
+                
+                // The "all" group is considered a special group and cannot be
+                // managed independently
+                if (!agroup.getHandle().equals("all")) {
                     groups.add(agroup);
                 }
             }
         }
+        
         public List getGroups() {
             return groups;
         }

Modified: roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java (original)
+++ roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java Thu Apr 12 17:02:00 2007
@@ -28,8 +28,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.planet.business.PropertiesManager;
-import org.apache.roller.planet.ui.admin.struts.forms.PlanetSubscriptionFormEx;
+import org.apache.roller.planet.ui.admin.struts.forms.PlanetSubscriptionForm;
 import org.apache.struts.action.ActionError;
 import org.apache.struts.action.ActionErrors;
 import org.apache.struts.action.ActionForm;
@@ -42,10 +41,8 @@
 import org.apache.roller.planet.business.PlanetFactory;
 import org.apache.roller.planet.business.PlanetManager;
 import org.apache.roller.planet.pojos.PlanetData;
-import org.apache.roller.planet.util.Technorati;
 import org.apache.roller.planet.pojos.PlanetGroupData;
 import org.apache.roller.planet.pojos.PlanetSubscriptionData;
-import org.apache.roller.planet.pojos.PropertyData;
 import org.apache.roller.ui.core.BasePageModel;
 import org.apache.roller.ui.core.RollerSession;
 
@@ -54,7 +51,7 @@
  * Add, remove, and view existing subscriptions in a group.
  * If no group is specified via the groupHandle parameter, then uses "external".
  *
- * @struts.action name="planetSubscriptionFormEx" path="/roller-ui/admin/planetSubscriptions"
+ * @struts.action name="planetSubscriptionForm" path="/roller-ui/admin/planetSubscriptions"
  *                scope="request" parameter="method"
  *
  * @struts.action-forward name="planetSubscriptions.page"
@@ -62,10 +59,12 @@
  */
 public final class PlanetSubscriptionsAction extends DispatchAction {
     
-    private static Log logger = LogFactory.getLog(PlanetSubscriptionsAction.class);
+    private static Log log = LogFactory.getLog(PlanetSubscriptionsAction.class);
     
     
-    /** Populate page model and forward to subscription page */
+    /** 
+     * Populate page model and forward to subscription page 
+     */
     public ActionForward getSubscriptions(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
@@ -74,7 +73,7 @@
         try {
             if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
                 PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
-                PlanetSubscriptionFormEx form = (PlanetSubscriptionFormEx)actionForm;
+                PlanetSubscriptionForm form = (PlanetSubscriptionForm)actionForm;
                 if (request.getParameter("feedUrl") != null) {
                     String feedUrl = request.getParameter("feedUrl");
                     PlanetSubscriptionData sub =
@@ -84,9 +83,10 @@
                     form.doReset(mapping, request);
                 }
                 
-                String groupHandle = request.getParameter("groupHandle");
-                groupHandle = (groupHandle == null) ? form.getGroupHandle() : groupHandle;
-                groupHandle = (groupHandle == null) ? "external" : groupHandle;
+                String groupHandle = form.getGroupHandle();
+                if (groupHandle == null) {
+                    groupHandle = "all";
+                }
                 
                 PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
                 PlanetGroupData targetGroup = pmgr.getGroup(defaultPlanet, groupHandle);
@@ -105,7 +105,9 @@
     }
     
     
-    /** Cancel editing, reset form */
+    /** 
+     * Cancel editing, reset form 
+     */
     public ActionForward cancelEditing(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
@@ -114,13 +116,14 @@
         try {
             if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
                 PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
-                PlanetSubscriptionFormEx form = (PlanetSubscriptionFormEx)actionForm;
+                PlanetSubscriptionForm form = (PlanetSubscriptionForm)actionForm;
                 
                 form.doReset(mapping, request);
                 
-                String groupHandle = request.getParameter("groupHandle");
-                groupHandle = (groupHandle == null) ? form.getGroupHandle() : groupHandle;
-                groupHandle = (groupHandle == null) ? "external" : groupHandle;
+                String groupHandle = form.getGroupHandle();
+                if (groupHandle == null) {
+                    groupHandle = "all";
+                }
                 
                 PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
                 PlanetGroupData targetGroup = pmgr.getGroup(defaultPlanet, groupHandle);
@@ -139,7 +142,9 @@
     }
     
     
-    /** Delete subscription, reset form  */
+    /** 
+     * Delete subscription, reset form  
+     */
     public ActionForward deleteSubscription(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
@@ -149,14 +154,15 @@
             //RollerRequest rreq = RollerRequest.getRollerRequest(request);
             if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
                 PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
-                PlanetSubscriptionFormEx form = (PlanetSubscriptionFormEx)actionForm;
+                PlanetSubscriptionForm form = (PlanetSubscriptionForm)actionForm;
                 if (form.getId() != null) {
                     PlanetSubscriptionData sub =
                             pmgr.getSubscriptionById(form.getId());
                     
-                    String groupHandle = request.getParameter("groupHandle");
-                    groupHandle = (groupHandle == null) ? form.getGroupHandle() : groupHandle;
-                    groupHandle = (groupHandle == null) ? "external" : groupHandle;
+                    String groupHandle = form.getGroupHandle();
+                    if (groupHandle == null) {
+                        groupHandle = "all";
+                    }
                     
                     PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
                     PlanetGroupData targetGroup = pmgr.getGroup(defaultPlanet, groupHandle);
@@ -164,8 +170,6 @@
                     targetGroup.getSubscriptions().remove(sub);
                     pmgr.deleteSubscription(sub);
                     PlanetFactory.getPlanet().flush();
-                    // TODO: why release here?
-                    PlanetFactory.getPlanet().release();
                     
                     form.doReset(mapping, request);
                     
@@ -191,60 +195,74 @@
     }
     
     
-    /** Save subscription, add to current group */
+    /** 
+     * Save subscription, add to current group 
+     */
     public ActionForward saveSubscription(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
         
+        log.debug("Save Subscription");
+        
         ActionForward forward = mapping.findForward("planetSubscriptions.page");
         try {
             PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
-            PlanetSubscriptionFormEx form = (PlanetSubscriptionFormEx)actionForm;
-            
-            String groupHandle = request.getParameter("groupHandle");
-            groupHandle = (groupHandle == null) ? form.getGroupHandle() : groupHandle;
-            groupHandle = (groupHandle == null) ? "external" : groupHandle;
-            
-            PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
-            PlanetGroupData targetGroup = pmgr.getGroup(defaultPlanet, groupHandle);
+            PlanetSubscriptionForm form = (PlanetSubscriptionForm)actionForm;
             
             if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
                 
+                String groupHandle = form.getGroupHandle();
+                if (groupHandle == null) {
+                    groupHandle = "all";
+                }
+                
+                log.debug("Selected group = "+groupHandle);
+                
+                PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
+                PlanetGroupData targetGroup = pmgr.getGroup(defaultPlanet, groupHandle);
+                
                 ActionMessages messages = new ActionMessages();
-                PlanetSubscriptionData sub = null;
                 ActionErrors errors = validate(pmgr, form);
                 if (errors.isEmpty()) {
+                    
+                    PlanetSubscriptionData sub = null;
                     if (form.getId() == null || form.getId().trim().length() == 0) {
+                        
                         // Adding new subscription to group
-                        // But, does subscription to that feed already exist?
-                        if (form.getFeedURL() != null) {
-                            sub = pmgr.getSubscription(form.getFeedURL());
-                        }
+                        // Does subscription to that feed already exist?
+                        sub = pmgr.getSubscription(form.getFeedURL());
                         if (sub != null) {
-                            // Yes, we'll use it instead
+                            log.debug("Adding Existing Subscription");
+                            
+                            // Subscription already exists
                             messages.add(null, new ActionMessage(
                                     "planetSubscription.foundExisting", sub.getTitle()));
                         } else {
-                            // No, add new subscription
+                            log.debug("Adding New Subscription");
+                            
+                            // Add new subscription
                             sub = new PlanetSubscriptionData();
                             form.copyTo(sub, request.getLocale());
                             
                             // the form copy is a little dumb and will set the id value
                             // to empty string if it didn't have a value before, which means
                             // that this object would not be considered new
-                            if(sub.getId() != null && sub.getId().trim().equals("")) {
-                                sub.setId(null);
-                            }
+                            sub.setId(null);
                             
                             pmgr.saveSubscription(sub);
                         }
+                        
+                        // add the subscription to our group
                         targetGroup.getSubscriptions().add(sub);
                         
                     } else {
+                        log.debug("Updating Subscription");
+                        
                         // User editing an existing subscription within a group
                         sub = pmgr.getSubscriptionById(form.getId());
                         form.copyTo(sub, request.getLocale());
                     }
+                    
                     form.setGroupHandle(groupHandle);
                     pmgr.saveGroup(targetGroup);
                     PlanetFactory.getPlanet().flush();
@@ -256,12 +274,15 @@
                 } else {
                     saveErrors(request, errors);
                 }
+                
+                request.setAttribute("model",
+                    new SubscriptionsPageModel(
+                    targetGroup, request, response, mapping, form));
+                
             } else {
                 forward = mapping.findForward("access-denied");
             }
-            request.setAttribute("model",
-                    new SubscriptionsPageModel(
-                    targetGroup, request, response, mapping, form));
+            
         } catch (RollerException re) {
             ActionErrors errors = new ActionErrors();
             errors.add(null, new ActionError(
@@ -272,79 +293,51 @@
             errors.add(null, new ActionError(
                     "planetSubscriptions.error.duringSave", e.getMessage()));
             saveErrors(request, errors);
-            logger.error("Unexpected error saving subscription", e);
+            this.log.error("Unexpected error saving subscription", e);
         }
+        
         return forward;
     }
     
     
-    /** Validate posted subscription, fill in blanks via Technorati */
+    /** 
+     * Validate posted subscription, fill in blanks via Technorati 
+     */
     private ActionErrors validate(
-            PlanetManager pmgr, PlanetSubscriptionFormEx form) {
-        
-        String technoratiTitle = null;
-        String technoratiFeedUrl = null;
-        int inboundlinks = -1;
-        int inboundblogs = -1;
-        if (form.getSiteURL()!=null && form.getSiteURL().trim().length() > 0) {
-            try {
-                PropertiesManager props = PlanetFactory.getPlanet().getPropertiesManager();
-                Technorati technorati = null;
-                PropertyData proxyHostProp = props.getProperty("proxyHost");
-                PropertyData proxyPortProp = props.getProperty("proxyPort");
-                if (proxyHostProp != null && proxyPortProp != null) {
-                    technorati = new Technorati(proxyHostProp.getValue(), Integer.parseInt(proxyPortProp.getValue()));
-                } else {
-                    technorati = new Technorati();
-                }
-                Technorati.Result result =
-                        technorati.getBloginfo(form.getSiteURL());
-                technoratiTitle = result.getWeblog().getName();
-                technoratiFeedUrl = result.getWeblog().getRssurl();
-                form.setInboundlinks(result.getWeblog().getInboundlinks());
-                form.setInboundblogs(result.getWeblog().getInboundblogs());
-            } catch (Exception e) {
-                logger.debug("Unable to contact Technorati", e);
-            }
-        }
+            PlanetManager pmgr, PlanetSubscriptionForm form) {
         
         ActionErrors errors = new ActionErrors();
+        
         if (form.getTitle()==null || form.getTitle().trim().length()==0) {
-            if (technoratiTitle!=null && technoratiTitle.trim().length()>0) {
-                form.setTitle(technoratiTitle);
-            } else {
-                errors.add(null,
-                        new ActionError("planetSubscription.error.title"));
-            }
+            errors.add(null, new ActionError("planetSubscription.error.title"));
         }
+        
         if (form.getFeedURL()==null || form.getFeedURL().trim().length()==0) {
-            if (technoratiFeedUrl!=null && technoratiFeedUrl.trim().length()>0) {
-                form.setFeedURL(technoratiFeedUrl);
-            } else {
-                errors.add(null,
-                        new ActionError("planetSubscription.error.feedUrl"));
-            }
+            errors.add(null, new ActionError("planetSubscription.error.feedUrl"));
         }
+        
         if (form.getSiteURL()==null || form.getSiteURL().trim().length()==0) {
-            errors.add(null,
-                    new ActionError("planetSubscription.error.siteUrl"));
+            errors.add(null, new ActionError("planetSubscription.error.siteUrl"));
         }
+        
         return errors;
     }
     
     
-    /** Page model, includes subscriptions in "external" group */
+    /** 
+     * Page model, includes subscriptions in "external" group 
+     */
     public class SubscriptionsPageModel extends BasePageModel {
         private List subscriptions = null;
         private boolean unconfigured = false;
-        private PlanetSubscriptionFormEx form = null;
+        private PlanetSubscriptionForm form = null;
         
         public SubscriptionsPageModel(
                 PlanetGroupData group,
                 HttpServletRequest request,
                 HttpServletResponse response,
                 ActionMapping mapping,
-                PlanetSubscriptionFormEx form) throws RollerException {
+                PlanetSubscriptionForm form) throws RollerException {
             super("dummy", request, response, mapping);
             this.form = form;
             if (group != null) {
@@ -356,7 +349,7 @@
         }
         
         public String getTitle() {
-            if (!form.getGroupHandle().equals("external")) {
+            if (!form.getGroupHandle().equals("all")) {
                 return MessageFormat.format(
                         bundle.getString("planetSubscriptions.titleGroup"),
                         new Object[] {form.getGroupHandle()});

Modified: roller/trunk/src/org/apache/roller/planet/ui/admin/struts/forms/PlanetSubscriptionForm.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/planet/ui/admin/struts/forms/PlanetSubscriptionForm.java?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/src/org/apache/roller/planet/ui/admin/struts/forms/PlanetSubscriptionForm.java (original)
+++ roller/trunk/src/org/apache/roller/planet/ui/admin/struts/forms/PlanetSubscriptionForm.java Thu Apr 12 17:02:00 2007
@@ -1,274 +1,130 @@
 package org.apache.roller.planet.ui.admin.struts.forms;
 
+import java.io.Serializable;
 import org.apache.roller.RollerException;
 import java.util.Locale;
+import org.apache.struts.action.ActionForm;
+
 
 /**
- * Generated by XDoclet/ejbdoclet/strutsform. This class can be further processed with XDoclet/webdoclet/strutsconfigxml and XDoclet/webdoclet/strutsvalidationxml.
+ * Formbean for planet subscriptions action.
  *
  * @struts.form name="planetSubscriptionForm"
  */
-public class PlanetSubscriptionForm
-    extends    org.apache.struts.action.ActionForm
-    implements java.io.Serializable
-{
-    protected java.util.Set groups;
+public class PlanetSubscriptionForm extends ActionForm implements Serializable {
+    
     protected java.lang.String id;
     protected java.lang.String feedURL;
-    protected java.util.Date lastUpdated;
     protected java.lang.String siteURL;
     protected java.lang.String title;
-    protected java.lang.String author;
-    protected int inboundlinks;
-    protected int inboundblogs;
-    protected java.lang.String name;
-    protected java.lang.String URL;
-    protected java.util.List entries;
-
+    private String groupHandle = null;
+    
+    
     /** Default empty constructor. */
     public PlanetSubscriptionForm() {}
-
+    
     /** Constructor that takes the data object as argument. */
-    public PlanetSubscriptionForm(org.apache.roller.planet.pojos.PlanetSubscriptionData dataHolder, java.util.Locale locale) throws RollerException
-    {
-       copyFrom(dataHolder, locale);
-    }
-
-    public java.util.Set getGroups()
-    {
-        return this.groups;
+    public PlanetSubscriptionForm(org.apache.roller.planet.pojos.PlanetSubscriptionData dataHolder, java.util.Locale locale) throws RollerException {
+        copyFrom(dataHolder, locale);
     }
-
-   /** 
-    */
-    public void setGroups( java.util.Set groups )
-    {
-        this.groups = groups;
+    
+    
+    public String getGroupHandle() {
+        return groupHandle;
+    }
+    
+    public void setGroupHandle(String groupHandle) {
+        this.groupHandle = groupHandle;
     }
-
-    public java.lang.String getId()
-    {
+    
+    public java.lang.String getId() {
         return this.id;
     }
-
-   /** 
-    */
-    public void setId( java.lang.String id )
-    {
+    
+    public void setId( java.lang.String id ) {
         this.id = id;
     }
-
-    public java.lang.String getFeedURL()
-    {
+    
+    public java.lang.String getFeedURL() {
         return this.feedURL;
     }
-
-   /** 
-    */
-    public void setFeedURL( java.lang.String feedURL )
-    {
+    
+    public void setFeedURL( java.lang.String feedURL ) {
         this.feedURL = feedURL;
     }
-
-    public java.util.Date getLastUpdated()
-    {
-        return this.lastUpdated;
-    }
-
-   /** 
-    */
-    public void setLastUpdated( java.util.Date lastUpdated )
-    {
-        this.lastUpdated = lastUpdated;
-    }
-
-    public java.lang.String getSiteURL()
-    {
+    
+    public java.lang.String getSiteURL() {
         return this.siteURL;
     }
-
-   /** 
-    */
-    public void setSiteURL( java.lang.String siteURL )
-    {
+    
+    public void setSiteURL( java.lang.String siteURL ) {
         this.siteURL = siteURL;
     }
-
-    public java.lang.String getTitle()
-    {
+    
+    public java.lang.String getTitle() {
         return this.title;
     }
-
-   /** 
-    */
-    public void setTitle( java.lang.String title )
-    {
+    
+    public void setTitle( java.lang.String title ) {
         this.title = title;
     }
-
-    public java.lang.String getAuthor()
-    {
-        return this.author;
-    }
-
-   /** 
-    */
-    public void setAuthor( java.lang.String author )
-    {
-        this.author = author;
-    }
-
-    public int getInboundlinks()
-    {
-        return this.inboundlinks;
-    }
-
-   /** 
-    */
-    public void setInboundlinks( int inboundlinks )
-    {
-        this.inboundlinks = inboundlinks;
-    }
-
-    public int getInboundblogs()
-    {
-        return this.inboundblogs;
-    }
-
-   /** 
-    */
-    public void setInboundblogs( int inboundblogs )
-    {
-        this.inboundblogs = inboundblogs;
-    }
-
-    public java.lang.String getName()
-    {
-        return this.name;
-    }
-
-   /** 
-    */
-    public void setName( java.lang.String name )
-    {
-        this.name = name;
-    }
-
-    public java.lang.String getURL()
-    {
-        return this.URL;
-    }
-
-   /** 
-    */
-    public void setURL( java.lang.String URL )
-    {
-        this.URL = URL;
-    }
-
-    public java.util.List getEntries()
-    {
-        return this.entries;
-    }
-
-   /** 
-    */
-    public void setEntries( java.util.List entries )
-    {
-        this.entries = entries;
-    }
-
+    
+    
     /**
      * Copy values from this form bean to the specified data object.
      * Only copies primitive types (Boolean, boolean, String, Integer, int, Timestamp, Date)
      */
-    public void copyTo(org.apache.roller.planet.pojos.PlanetSubscriptionData dataHolder, Locale locale) throws RollerException
-    {
-
-        dataHolder.setId(this.id);
-
+    public void copyTo(org.apache.roller.planet.pojos.PlanetSubscriptionData dataHolder, Locale locale) throws RollerException {
+        
         dataHolder.setFeedURL(this.feedURL);
-
-        dataHolder.setLastUpdated(this.lastUpdated);
-
+        
         dataHolder.setSiteURL(this.siteURL);
-
+        
         dataHolder.setTitle(this.title);
-
-        dataHolder.setAuthor(this.author);
-
-        dataHolder.setInboundlinks(this.inboundlinks);
-
-        dataHolder.setInboundblogs(this.inboundblogs);
-
-        dataHolder.setTitle(this.name);
     }
-
+    
+    
     /**
      * Copy values from specified data object to this form bean.
      * Includes all types.
      */
-    public void copyFrom(org.apache.roller.planet.pojos.PlanetSubscriptionData dataHolder, Locale locale) throws RollerException
-    {
-
+    public void copyFrom(org.apache.roller.planet.pojos.PlanetSubscriptionData dataHolder, Locale locale) throws RollerException {
+        
         this.id = dataHolder.getId();
-
+        
         this.feedURL = dataHolder.getFeedURL();
-
-        this.lastUpdated = dataHolder.getLastUpdated();
-
+        
         this.siteURL = dataHolder.getSiteURL();
-
+        
         this.title = dataHolder.getTitle();
-
-        this.author = dataHolder.getAuthor();
-
-        this.inboundlinks = dataHolder.getInboundlinks();
-
-        this.inboundblogs = dataHolder.getInboundblogs();
-
-        this.name = dataHolder.getName();
-
-        this.URL = dataHolder.getURL();
-
+        
     }
-
+    
+    
     public void doReset(
-    	org.apache.struts.action.ActionMapping mapping, 
-    	javax.servlet.ServletRequest request)
-    {
-
+            org.apache.struts.action.ActionMapping mapping,
+            javax.servlet.ServletRequest request) {
+        
         this.id = null;
-
+        
         this.feedURL = null;
-
-        this.lastUpdated = null;
-
+        
         this.siteURL = null;
-
+        
         this.title = null;
-
-        this.author = null;
-
-        this.inboundlinks = 0;
-
-        this.inboundblogs = 0;
-
-        this.name = null;
-
-        this.URL = null;
-
+        
     }
+    
     public void reset(
-    	org.apache.struts.action.ActionMapping mapping, 
-    	javax.servlet.ServletRequest request)
-    {
+            org.apache.struts.action.ActionMapping mapping,
+            javax.servlet.ServletRequest request) {
         doReset(mapping, request);
     }
+    
     public void reset(
-    	org.apache.struts.action.ActionMapping mapping, 
-    	javax.servlet.http.HttpServletRequest request)
-    {
+            org.apache.struts.action.ActionMapping mapping,
+            javax.servlet.http.HttpServletRequest request) {
         doReset(mapping, request);
     }
+    
 }

Modified: roller/trunk/src/org/apache/roller/ui/core/RollerContext.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/core/RollerContext.java?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/src/org/apache/roller/ui/core/RollerContext.java (original)
+++ roller/trunk/src/org/apache/roller/ui/core/RollerContext.java Thu Apr 12 17:02:00 2007
@@ -47,6 +47,8 @@
 import org.apache.roller.business.Roller;
 import org.apache.roller.business.RollerFactory;
 import org.apache.roller.business.runnable.ThreadManager;
+import org.apache.roller.planet.business.Planet;
+import org.apache.roller.planet.business.PlanetFactory;
 import org.apache.roller.ui.core.plugins.UIPluginManager;
 import org.apache.roller.ui.core.plugins.UIPluginManagerImpl;
 import org.apache.roller.ui.core.security.AutoProvision;
@@ -149,6 +151,22 @@
             throw new RuntimeException(t);
         }
         
+        // Initialize Planet if necessary
+        if(RollerConfig.getBooleanProperty("planet.aggregator.enabled")) {
+            try {
+                Planet planet = PlanetFactory.getPlanet();
+                
+                setupPlanetProperties();
+                
+                planet.flush();
+                planet.release();
+                
+            } catch (Throwable t) {
+                log.fatal("Roller Planet initialization failed", t);
+                throw new RuntimeException(t);
+            }
+        }
+        
         log.info("Roller Weblogger Initialization Complete");
     }
     
@@ -381,6 +399,15 @@
             defmap.addSecureUrl("/**<!-- need to remove this when uncommenting -->/*.do*", insecureDef);
         }
         */
+    }
+    
+    
+    /**
+     * Initialize the Roller Planet runtime configuration.
+     */
+    private void setupPlanetProperties() throws Exception {
+        // Planet PropertiesManager initializes itself
+        PlanetFactory.getPlanet().getPropertiesManager();
     }
     
     

Modified: roller/trunk/tools/roller-planet/roller-planet-business.jar
URL: http://svn.apache.org/viewvc/roller/trunk/tools/roller-planet/roller-planet-business.jar?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
Binary files - no diff available.

Modified: roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ roller/trunk/web/WEB-INF/classes/ApplicationResources.properties Thu Apr 12 17:02:00 2007
@@ -1184,7 +1184,7 @@
 planetGroups.error.title=Title is required
 planetGroups.error.handle=Handle is required
 planetGroups.error.duringSave=Duplicate group? - {0}
-planetGroups.error.nameReserved=Can't use handle 'all' or 'external'
+planetGroups.error.nameReserved=Can't use handle 'all'
 planetGroups.error.deleting=Error deleting object
 
 # ----------------------------------------------------------------- referers.jsp

Modified: roller/trunk/web/WEB-INF/jsps/admin/PlanetSubscriptions.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/admin/PlanetSubscriptions.jsp?view=diff&rev=528288&r1=528287&r2=528288
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/admin/PlanetSubscriptions.jsp (original)
+++ roller/trunk/web/WEB-INF/jsps/admin/PlanetSubscriptions.jsp Thu Apr 12 17:02:00 2007
@@ -20,38 +20,38 @@
 <!--
 function cancelEditing()
 {
-    document.planetSubscriptionFormEx.method.value = "cancelEditing";
-    document.planetSubscriptionFormEx.submit();
+    document.planetSubscriptionForm.method.value = "cancelEditing";
+    document.planetSubscriptionForm.submit();
 }
 function deleteSubscription()
 {
-    document.planetSubscriptionFormEx.method.value = "deleteSubscription";
-    document.planetSubscriptionFormEx.submit();
+    document.planetSubscriptionForm.method.value = "deleteSubscription";
+    document.planetSubscriptionForm.submit();
 }
 // -->
 </script>
 
 <h1>
     <fmt:message key="planetSubscriptions.title" />    
-    <c:if test='${planetSubscriptionFormEx.groupHandle != "external"}' >
-       &nbsp;[group: <c:out value="${planetSubscriptionFormEx.groupHandle}" />]
+    <c:if test='${planetSubscriptionForm.groupHandle != "all"}' >
+       &nbsp;[group: <c:out value="${planetSubscriptionForm.groupHandle}" />]
     </c:if>        
 </h1>
 
 <c:choose>
-    <c:when test='${empty planetSubscriptionFormEx.id && planetSubscriptionFormEx.groupHandle == "external"}' >
+    <c:when test='${empty planetSubscriptionForm.id && planetSubscriptionForm.groupHandle == "all"}' >
         <p class="subtitle"><fmt:message key="planetSubscriptions.subtitle.addMain" /></p>
         <p><fmt:message key="planetSubscriptions.prompt.addMain" /></p>
     </c:when>
-    <c:when test='${empty planetSubscriptionFormEx.id && planetSubscriptionFormEx.groupHandle != "external"}' >
+    <c:when test='${empty planetSubscriptionForm.id && planetSubscriptionForm.groupHandle != "all"}' >
         <p class="subtitle">
             <fmt:message key="planetSubscriptions.subtitle.add" >
-                <fmt:param value="${planetSubscriptionFormEx.groupHandle}" />
+                <fmt:param value="${planetSubscriptionForm.groupHandle}" />
             </fmt:message>
         </p>
         <p><fmt:message key="planetSubscriptions.prompt.add" /></p>
     </c:when>
-    <c:when test="${!empty planetSubscriptionFormEx.id}" >
+    <c:when test="${!empty planetSubscriptionForm.id}" >
         <p class="subtitle"><fmt:message key="planetSubscriptions.subtitle.edit" /></p>
         <p><fmt:message key="planetSubscriptions.prompt.edit" /></p>
     </c:when>
@@ -61,8 +61,6 @@
     <html:hidden property="method" value="saveSubscription" />
     <html:hidden property="id" />
     <html:hidden property="groupHandle" />
-    <html:hidden property="inboundlinks" />
-    <html:hidden property="inboundblogs" />
 
     <div class="formrow">
         <label for="title" class="formrow" />
@@ -97,7 +95,7 @@
         <input type="button" 
             value='<fmt:message key="planetSubscriptions.button.cancel" />' 
             onclick="cancelEditing()"/>
-        <c:if test="${!empty planetSubscriptionFormEx.id}" >
+        <c:if test="${!empty planetSubscriptionForm.id}" >
             &nbsp;&nbsp;
             <input type="button" 
                value='<fmt:message key="planetSubscriptions.button.delete" />' 
@@ -109,8 +107,8 @@
 
     <h2>
         <fmt:message key="planetSubscriptions.existingTitle" />
-        <c:if test='${planetSubscriptionFormEx.groupHandle != "external"}' >
-           &nbsp;[group: <c:out value="${planetSubscriptionFormEx.groupHandle}" />]
+        <c:if test='${planetSubscriptionForm.groupHandle != "all"}' >
+           &nbsp;[group: <c:out value="${planetSubscriptionForm.groupHandle}" />]
         </c:if>
     </h2>
     <p><i><fmt:message key="planetSubscriptions.existingPrompt" /></i></p>
@@ -146,7 +144,7 @@
                             id="method" value="getSubscriptions" />                   
                         <roller:linkparam 
                             id="groupHandle" 
-                            name="planetSubscriptionFormEx" 
+                            name="planetSubscriptionForm" 
                             property="groupHandle" />                   
                         <roller:linkparam 
                             id="feedUrl" name="subscription" property="feedURL" />                   



Mime
View raw message