portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r526860 - /portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java
Date Mon, 09 Apr 2007 18:06:08 GMT
Author: taylor
Date: Mon Apr  9 11:06:07 2007
New Revision: 526860

URL: http://svn.apache.org/viewvc?view=rev&rev=526860
Log:
configure hostname criterion to parse prefix of hostname

Modified:
    portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java

Modified: portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java?view=diff&rev=526860&r1=526859&r2=526860
==============================================================================
--- portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java
(original)
+++ portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java
Mon Apr  9 11:06:07 2007
@@ -29,6 +29,13 @@
 public class HostnameCriterionResolver extends StandardResolver implements
         RuleCriterionResolver
 {
+    boolean useDotPrefix = false;
+    
+    public HostnameCriterionResolver(boolean usePrefix)
+    {
+        super();
+        this.useDotPrefix = usePrefix;
+    }
 
     /*
      * (non-Javadoc)
@@ -37,7 +44,7 @@
      */
     public boolean isControl(RuleCriterion criterion)
     {
-        return false;
+        return true;
     }
 
     /*
@@ -47,49 +54,22 @@
      */
     public boolean isNavigation(RuleCriterion criterion)
     {
-        return true;
+        return false;
     }
 
     public String resolve(RequestContext context, RuleCriterion criterion)
     {
-        return getHostname(context.getRequest().getServerName());
-    }
-
-    /**
-     * extracts the hostname from the servername from RequestContext
-     * 
-     * @param servername
-     *            server name from request
-     * @return hostname extracted from server name
-     */
-    public String getHostname(String servername)
-    {
-        String hostname = null;
-
-        if (servername != null)
+        String serverName = context.getRequest().getServerName();        
+        if (useDotPrefix)
         {
-            int idx = servername.indexOf(".");
+            int idx = serverName.indexOf(".");
             if (idx != -1)
             {
-                hostname = servername.substring(idx, servername.length());
-            } else
-            {
-                // maybe we already have the hostname
-                // testing for IPv6 IP Address
-                idx = servername.indexOf(":");
-                if (idx != -1)
-                {
-                    // TODO resolving IP Address?
-                    // for now we take this as the host name
-                    hostname = servername;
-                } else
-                {
-                    // looks like hostname==servername
-                    hostname = servername;
-                }
+                // SUFFIX: hostname = servername.substring(idx + 1, servername.length());
+                serverName = serverName.substring(0, idx);
             }
         }
-        return hostname;
+        return serverName;
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message