incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r534154 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main: java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
Date Tue, 01 May 2007 16:55:09 GMT
Author: jwaldman
Date: Tue May  1 09:55:08 2007
New Revision: 534154

URL: http://svn.apache.org/viewvc?view=rev&rev=534154
Log:
ADFFACES-478
https://issues.apache.org/jira/browse/ADFFACES-478
servlet exception when browser is unknown because the Agent for unknown browser had null attributes.

Now they have "unknown" String attributes so that we won't get NPEs when code uses the Agent's
attribute values in comparisons.

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java?view=diff&rev=534154&r1=534153&r2=534154
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
Tue May  1 09:55:08 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,14 +210,20 @@
         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("UNKNOWN_AGENT_ATTRIBUTES_CREATE_WITH_NULL", userAgent);
+    // Log warning message that we are setting the agent entry to unknown attributes
+    _LOG.warning("UNKNOWN_AGENT_ATTRIBUTES_CREATE_WITH_UNKNOWN", 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
@@ -226,7 +235,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;
@@ -235,8 +244,7 @@
       agentObj.setType(Agent.TYPE_TELNET);
       versionStartIndex = "OracleJDevMobile_ITS".length()+1;
     }
-    else
-      if (pdaIndex > -1)
+    else if (pdaIndex > -1)
     {
 
       agentObj.setType(Agent.TYPE_PDA);
@@ -244,10 +252,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);
@@ -282,9 +290,9 @@
         agentObj.__addRequestCapability(CapabilityKey.getCapabilityKey(capabilityName,true),capabilityValue);
       }
     }
-    if (returnNullAgentObj)
+    if (returnUnknownAgentObj)
     {
-      _populateNullAgentImpl(agent, agentObj);
+      _populateUnknownAgentImpl(agent, agentObj);
     }
   }
 
@@ -517,7 +525,7 @@
     // map device hint to agent type
     if (wirelessType == null)
     {
-      _populateNullAgentImpl(agent, agentObj);
+      _populateUnknownAgentImpl(agent, agentObj);
       return;
     }
 
@@ -852,6 +860,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);
 
 }

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts?view=diff&rev=534154&r1=534153&r2=534154
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
Tue May  1 09:55:08 2007
@@ -21,8 +21,8 @@
 <!DOCTYPE resources SYSTEM "rts.dtd">
 <resources xmlns="http://myfaces.apache.org/trinidad/rts" package="org.apache.myfaces.trinidadinternal.resource">
 
-<!-- UNKNOWN_AGENT_ATTRIBUTES_CREATE_WITH_NULL -->
-<resource key="UNKNOWN_AGENT_ATTRIBUTES_CREATE_WITH_NULL">The User-Agent "{0}" is unknown;
creating an agent with null agent attributes.</resource>
+<!-- UNKNOWN_AGENT_ATTRIBUTES_CREATE_WITH_UNKNOWN -->
+<resource key="UNKNOWN_AGENT_ATTRIBUTES_CREATE_WITH_UNKNOWN">The User-Agent "{0}" is
unknown; creating an agent with "unknown" agent attributes.</resource>
 
 <!-- UNKNOWN_AGENT_TYPE_CREATE_WITH_NULL -->
 <resource key="UNKNOWN_AGENT_TYPE_CREATE_WITH_NULL">The agent type is unknown; creating
an agent with null agent attributes.</resource>



Mime
View raw message