incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r535047 - /incubator/adffaces/branches/faces-1_2-070316/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
Date Fri, 04 May 2007 00:54:52 GMT
Author: jwaldman
Date: Thu May  3 17:54:51 2007
New Revision: 535047

URL: http://svn.apache.org/viewvc?view=rev&rev=535047
Log:
ADFFACES=478 unknown agent yields ServletException
https://issues.apache.org/jira/browse/ADFFACES-478
I need this fix in the faces-1_2-070316 branch.

Modified:
    incubator/adffaces/branches/faces-1_2-070316/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java

Modified: incubator/adffaces/branches/faces-1_2-070316/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2-070316/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java?view=diff&rev=535047&r1=535046&r2=535047
==============================================================================
--- incubator/adffaces/branches/faces-1_2-070316/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
(original)
+++ incubator/adffaces/branches/faces-1_2-070316/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
Thu May  3 17:54:51 2007
@@ -49,6 +49,7 @@
   {
     AgentImpl agent = new AgentImpl();
 
+    // Get the RequestHeaderMap to help populate the agent
     Map<String, String> headerMap;
     if (facesContext != null)
     {
@@ -60,12 +61,14 @@
     }
 
     //TODO: Add declarative and extensible means for populating AgentImpl object
+    // the RequestHeaderMap helps populate the agent
     _populateAgentImpl(headerMap, agent);
 
     return agent;
   }
 
-
+  // The headerMap is the RequestHeaderMap from the externalContext. It is 
+  // consulted to correctly populate the agent
   private void _populateAgentImpl(Map<String, String> headerMap, AgentImpl agent)
   {
     
@@ -90,7 +93,7 @@
 
     if (userAgent == null)
     {
-      _populateNullAgentImpl(userAgent, agent);
+      _populateUnknownAgentImpl(userAgent, agent);
       return;
     }
     
@@ -207,16 +210,22 @@
         return;
     }
 
-    _populateNullAgentImpl(userAgent, agent);
+    _populateUnknownAgentImpl(userAgent, agent);
   }
 
-  private void _populateNullAgentImpl(String userAgent, AgentImpl agent)
+  private void _populateUnknownAgentImpl(String userAgent, AgentImpl agent)
   {
     // Log warning message that we are setting the agent entry to null
     _LOG.warning(
       "The User-Agent \"{0}\" is unknown;"+
-      " creating an agent with null agent attributes.", userAgent);
+      " creating an agent with unknown agent attributes.", userAgent);
     agent.setAgentEntryToNULL();
+    agent.setAgent(_UNKNOWN);
+    agent.setType(_UNKNOWN);
+    agent.setAgentVersion(_UNKNOWN);
+    agent.setPlatform(_UNKNOWN);
+    agent.setPlatformVersion(_UNKNOWN);
+    agent.setMakeModel(_UNKNOWN);
   }
 
   //populates the agent entry for DT access for either Telnet or PDA
@@ -228,7 +237,7 @@
     //the form of JDEVMobile user agent string will be:
     //OracleJDevMobile_[PDA or ITS]/[version](DeviceName:[device name];[capability1]:[capability
1 value];...)
 
-    boolean returnNullAgentObj = false;
+    boolean returnUnknownAgentObj = false;
     int itsIndex = agent.indexOf("ITS");
     int pdaIndex = agent.indexOf("PDA");
     int versionStartIndex = -1;
@@ -237,8 +246,7 @@
       agentObj.setType(Agent.TYPE_TELNET);
       versionStartIndex = "OracleJDevMobile_ITS".length()+1;
     }
-    else
-      if (pdaIndex > -1)
+    else if (pdaIndex > -1)
     {
 
       agentObj.setType(Agent.TYPE_PDA);
@@ -246,10 +254,10 @@
     }
     else
     {
-      returnNullAgentObj = true;
+      returnUnknownAgentObj = true;
     }
     //Now find the name of the device
-    if (!returnNullAgentObj){
+    if (!returnUnknownAgentObj){
       int versionEndIndex = agent.indexOf("(");
       String version = agent.substring(versionStartIndex,versionEndIndex);
       agentObj.setAgentVersion(version);
@@ -284,9 +292,9 @@
         agentObj.__addRequestCapability(CapabilityKey.getCapabilityKey(capabilityName,true),capabilityValue);
       }
     }
-    if (returnNullAgentObj)
+    if (returnUnknownAgentObj)
     {
-      _populateNullAgentImpl(agent, agentObj);
+      _populateUnknownAgentImpl(agent, agentObj);
     }
   }
 
@@ -519,7 +527,7 @@
     // map device hint to agent type
     if (wirelessType == null)
     {
-      _populateNullAgentImpl(agent, agentObj);
+      _populateUnknownAgentImpl(agent, agentObj);
       return;
     }
 
@@ -854,6 +862,7 @@
   }
 
   static final private String _IASW_DEVICE_HINT_PARAM = "X-Oracle-Device.Class";
+  static final private String _UNKNOWN = "unknown";
   static final private TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(AgentFactoryImpl.class);
 
 }



Mime
View raw message