Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Is this simple design what we want to support in Roller?

Design

From the administrator's point of view, once this proposal is implemented in Roller, all you have to do to enable multi-domain support in Roller is to add one configuration property to Roller for each blog that you would like to give it's own unique domain name to.

For example, on rollerweblogger.org, I wanted my dad's photo-physics blog to have it's own unique URL. So, I added this property to my roller-custom.properties file:

Code Block

weblog.absoluteurl.photophys=http://photophys.com
guice.backend.module=org.rollerweblogger.roller.JPAWebloggerModule

And I had to add that second line to hook in the mutli-domain implementation, so let's talk about that. The implementation is made up of these five parts:

  • Weblog.java: changed to return correct weblog URL based on weblog.absolute.* property
  • MutliDomainURLModel.java: new class to return correct URLs
  • MultiDomainURLStrategy.java: new class to return correct URLs
  • WeblogRequestMapper.java: changes to prevent weblogs from being referred to by two URLs
  • JPAWebloggerModule.java: new class to hook in MultiDomainURLStrategy.java

Now let's discuss each change.

Weblog.java

In this class, the only changes is to return the correct URL if the weblog is one for which a weblog.absolute.* URL is specified. The proposal is to make these changes directly to Roller's Weblog.java.

Seems kinda silly that a weblog's absolute URL is defined in two places, here and in the Weblog object itself. The URLStrategy is probably the right place for this logic.

Patches

There are two "patches" attached to Jira ROL-1670. One uploaded by Dave Johnson, the other by Sean Gilligan. They are described in the next two sections.

Dave's Patch

Dave's Patch (changedfiles-rol-1670.tgz) is actually a tarball containing all files that were changed or modified.

Sean's Patch

Sean's Patch (sean_simple_multidomain_support.patch) is a real patch. It has one other difference: rather than add the new files in the org.rollerweblogger.roller package they are in org.apache packages where their related classes live. This means that JPAMultiDomainWebloggerModule.java is the name of the Guice binding file, since it lives in the same package as JPAWebloggerModule.java that it is based upon.

Design

From the administrator's point of view, once this proposal is implemented in Roller, all you have to do to enable multi-domain support in Roller is to add one configuration property to Roller for each blog that you would like to give it's own unique domain name to.

For example, on rollerweblogger.org, I wanted my dad's photo-physics blog to have it's own unique URL. So, I added this property to my roller-custom.properties file:

Code Block

weblog.absoluteurl.photophys=http://photophys.com
guice.backend.module=org.rollerweblogger.roller.JPAWebloggerModule

And I had to add that second line to hook in the mutli-domain implementation, so let's talk about that. The implementation is made up of these five parts:

  • Weblog.java: changed to return correct weblog URL based on weblog.absolute.* property
  • MutliDomainURLModel.java: new class to return correct URLs
  • MultiDomainURLStrategy.java: new class to return correct URLs
  • WeblogRequestMapper.java: changes to prevent weblogs from being referred to by two URLs
  • JPAWebloggerModule.java: new class to hook in MultiDomainURLStrategy.java

Now let's discuss each change.

Weblog.java

In this class, the only change is to return the correct URL if the weblog is one for which a weblog.absolute.* URL is specified. The proposal is to make these changes directly to Roller's Weblog.java.

Seems kinda silly that a weblog's absolute URL is defined in two places, here and in the Weblog object itself. The URLStrategy is probably the right place for this logic.

Code Block

Index: src/java/org/apache/roller/weblogger/pojos/Weblog.java
==============
Code Block

Index: src/java/org/apache/roller/weblogger/pojos/Weblog.java
===================================================================
--- src/java/org/apache/roller/weblogger/pojos/Weblog.java	(revision 618002)
+++ src/java/org/apache/roller/weblogger/pojos/Weblog.java	(working copy)
@@ -30,7 +30,6 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.TimeZone;
-import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.roller.weblogger.WebloggerException;
@@ -45,6 +44,7 @@
 import org.apache.roller.weblogger.business.themes.ThemeManager;
 import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.util.UUIDGenerator;
+import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.util.I18nUtils;
 
 
@@ -838,10 +838,14 @@
      * @roller.wrapPojoMethod type="simple"
      */
     public String getAbsoluteURL() {
-        // TODO: ATLAS reconcile entry.getPermaLink() with new URLs
-        String relPath = WebloggerRuntimeConfig.getAbsoluteContextURL();
-        return relPath + "/" + getHandle();
-        //return URLUtilities.getWeblogURL(this, null, true);
+        String weblogAbsoluteURL = 
+            WebloggerConfig.getProperty("weblog.absoluteurl." + getHandle()); 
+        if (weblogAbsoluteURL != null) {
+            return weblogAbsoluteURL + "/" + getHandle();
+        } else {
+            String relPath = WebloggerRuntimeConfig.getAbsoluteContextURL();
+            return relPath + "/" + getHandle();
+        }
     }
     public void setAbsoluteURL(String url) {
         // noop

...

MultiDomainURLModel.java

In this class, the only changes change is to return the correct URL if the weblog is one for which a weblog.absolute.* URL is specified.

...

Code Block
package org.rollerweblogger.roller;

import org.apache.roller.weblogger.business.jpa.*;
import com.google.inject.Binder;
import com.google.inject.Module;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.business.BookmarkManager;
import org.apache.roller.weblogger.business.FileManager;
import org.apache.roller.weblogger.business.FileManagerImpl;
import org.apache.rollercommons.webloggerlogging.business.PropertiesManagerLogFactory;
import org.apache.roller.weblogger.business.URLStrategyBookmarkManager;
import org.apache.roller.weblogger.business.WebloggerFileManager;
import org.apache.roller.weblogger.business.UserManagerFileManagerImpl;
import org.apache.roller.weblogger.business.WeblogManagerPropertiesManager;
import org.apache.roller.weblogger.business.pings.AutoPingManagerURLStrategy;
import org.apache.roller.weblogger.business.pings.PingQueueManagerWeblogger;
import org.apache.roller.weblogger.business.pings.PingTargetManagerUserManager;
import org.apache.roller.weblogger.business.plugins.PluginManagerWeblogManager;
import org.apache.roller.weblogger.business.pluginspings.PluginManagerImplAutoPingManager;
import org.apache.roller.weblogger.business.referrerspings.RefererManagerPingQueueManager;
import org.apache.roller.weblogger.business.referrerspings.ReferrerQueueManagerPingTargetManager;
import org.apache.roller.weblogger.business.referrersplugins.ReferrerQueueManagerImplPluginManager;
import org.apache.roller.weblogger.business.runnableplugins.ThreadManagerPluginManagerImpl;
import org.apache.roller.weblogger.business.searchreferrers.IndexManagerRefererManager;
import org.apache.roller.weblogger.business.searchreferrers.IndexManagerImplReferrerQueueManager;
import org.apache.roller.weblogger.business.themesreferrers.ThemeManagerReferrerQueueManagerImpl;
import org.apache.roller.weblogger.business.themesrunnable.ThemeManagerImplThreadManager;

/**
 * Guice module for configuring JPA as Weblogger-backend.
 */
public class JPAWebloggerModule implements Module {
    private static final Log logger = LogFactory.getLog(JPAWebloggerModule.class);
    
    public void configure(Binder binder) {
        logger.info("Configuring Blogging Roller Module with multi-domain support");

        binder.bind(Weblogger.class).to(JPAWebloggerImpl.class);        
        binder.bind(JPAPersistenceStrategy.class);       
        binder.bind(org.apache.roller.weblogger.planet.business.jpa.JPARollerPlanetPersistenceStrategy.class);
        import org.apache.roller.weblogger.business.search.IndexManager;
import org.apache.roller.weblogger.business.search.IndexManagerImpl;
import org.apache.roller.weblogger.business.themes.ThemeManager;
import org.apache.roller.weblogger.business.themes.ThemeManagerImpl;

/**
 * Guice module for configuring JPA as Weblogger-backend.
 */
public class JPAWebloggerModule implements Module {
    private static final Log logger = LogFactory.getLog(JPAWebloggerModule.class);
    
    public void configure(Binder binder) {
        logger.info("Configuring Blogging Roller Module with multi-domain support");

        binder.bind(AutoPingManagerWeblogger.class).to(JPAWebloggerImpl.class);     JPAAutoPingManagerImpl.class);   
        binder.bind(BookmarkManagerJPAPersistenceStrategy.class).to(;     JPABookmarkManagerImpl.class);  
        binder.bind(PingQueueManagerorg.apache.roller.weblogger.planet.business.jpa.JPARollerPlanetPersistenceStrategy.class).to(;
     JPAPingQueueManagerImpl.class);   
        binder.bind(PingTargetManagerAutoPingManager.class).to(     JPAPingTargetManagerImplJPAAutoPingManagerImpl.class);   
        binder.bind(PropertiesManagerBookmarkManager.class).to(     JPAPropertiesManagerImplJPABookmarkManagerImpl.class);   
        binder.bind(RefererManagerPingQueueManager.class).to(      JPARefererManagerImplJPAPingQueueManagerImpl.class);   
        binder.bind(ThreadManagerPingTargetManager.class).to(       JPAThreadManagerImplJPAPingTargetManagerImpl.class);  
        binder.bind(UserManagerPropertiesManager.class).to(         JPAUserManagerImplJPAPropertiesManagerImpl.class);   
        binder.bind(WeblogManagerRefererManager.class).to(       JPAWeblogManagerImplJPARefererManagerImpl.class);
   
     binder.bind(ThreadManager.class).to(         JPAThreadManagerImpl.class);  
        binder.bind(ReferrerQueueManagerUserManager.class).to(ReferrerQueueManagerImpl         JPAUserManagerImpl.class);   
        binder.bind(FileManagerWeblogManager.class).to(         FileManagerImplJPAWeblogManagerImpl.class);   
                
        binder.bind(IndexManagerReferrerQueueManager.class).to(        IndexManagerImplReferrerQueueManagerImpl.class); 
        binder.bind(PluginManagerFileManager.class).to(         PluginManagerImplFileManagerImpl.class);    
        binder.bind(ThemeManagerIndexManager.class).to(        ThemeManagerImplIndexManagerImpl.class);
        
        binder.bind(URLStrategyPluginManager.class).to(         MultiDomainURLStrategy.class);
    }
}

Patch for JIRA Issue

(Since JIRA seems to have a problem, I'll enter the JIRA text here, temporarily...

Issue Type

Improvement

Summary

Patch for Simple Multi-Domain support using roller-custom.properties

Description

A patch that will enable multii-domain support by configuring an entry for each weblog in roller-custom.properties, like this example:

weblog.absoluteurl.photophys=http://photophys.comImage Removed

...

PluginManagerImpl.class);    
        binder.bind(ThemeManager.class).to(        ThemeManagerImpl.class);
        
        binder.bind(URLStrategy.class).to(         MultiDomainURLStrategy.class);
    }
}

Comments

Please comment on the Roller dev mailing list.

Mailing list comments have led to an alternate proposal: Proposal Configurable Domain Resolution