You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2010/03/17 21:27:58 UTC
svn commit: r924470 -
/myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
Author: matzew
Date: Wed Mar 17 20:27:57 2010
New Revision: 924470
URL: http://svn.apache.org/viewvc?rev=924470&view=rev
Log:
TRINIDAD-1751 - NPE if User-Agent header is missing
thx to Harald Kuhn for the patch
Modified:
myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
Modified: myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java?rev=924470&r1=924469&r2=924470&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java (original)
+++ myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java Wed Mar 17 20:27:57 2010
@@ -71,16 +71,16 @@ public class AgentFactoryImpl implements
// consulted to correctly populate the agent
private void _populateAgentImpl(
FacesContext facesContext,
- Map<String, String> headerMap,
+ Map<String, String> headerMap,
AgentImpl agent)
{
-
+
String userAgent = headerMap.get("User-Agent");
String isEmail = null;
if (facesContext != null)
isEmail = facesContext.getExternalContext().getRequestParameterMap().
get(_EMAIL_PARAM);
-
+
if ("true".equals(isEmail))
{
_populateEmailAgentImpl(agent);
@@ -104,6 +104,12 @@ public class AgentFactoryImpl implements
return;
}
+ if (userAgent == null)
+ {
+ _populateUnknownAgentImpl(null, agent);
+ return;
+ }
+
//the useragent string for telnet and PDA design time will start with
//OracleJDevMobile because in each of these cases we know we have an
//exact match in the device repository for the agent name. This is
@@ -387,7 +393,7 @@ public class AgentFactoryImpl implements
agentObj.setAgent(Agent.AGENT_IE);
agentObj.setAgentVersion(version);
agentObj.setPlatform(Agent.PLATFORM_PPC);
-
+
boolean narrowScreenDevice = false;
if(uaPixels != null && uaPixels.length() > 0)
@@ -418,7 +424,7 @@ public class AgentFactoryImpl implements
{
agentObj.__addRequestCapability(TrinidadAgent.CAP_WIDTH,width);
agentObj.__addRequestCapability(TrinidadAgent.CAP_HEIGHT,height);
-
+
if (width.intValue() < TrinidadRenderingConstants.NARROW_SCREEN_PDA_MAX_WIDTH)
{
narrowScreenDevice = true;
@@ -433,15 +439,15 @@ public class AgentFactoryImpl implements
{
narrowScreenDevice = true;
}
-
+
if (narrowScreenDevice)
{
- agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
+ agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
Boolean.TRUE);
}
else
{
- agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
+ agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
Boolean.FALSE);
}
}
@@ -488,9 +494,9 @@ public class AgentFactoryImpl implements
agentObj.setAgentVersion(version);
agentObj.setPlatform(Agent.PLATFORM_BLACKBERRY);
agentObj.setMakeModel(makeModel);
- // Most of BlackBerry devices' widths are more than 240px, so
+ // Most of BlackBerry devices' widths are more than 240px, so
// don't consider BlackBerry as a narrow-screen PDA.
- agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
+ agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
Boolean.FALSE);
}
@@ -700,7 +706,7 @@ public class AgentFactoryImpl implements
// so just return. It will be handle by _populateGenricPDAImpl().
else if (agent.indexOf("MOT-") != -1 || agent.indexOf("Nokia") != -1)
{
- return;
+ return;
}
else
{
@@ -897,14 +903,14 @@ public class AgentFactoryImpl implements
}
}
}
-
+
/**
* Returns an AgentEntry for the email agents like Outlook 2007 and
* Thunderbird
*/
private void _populateEmailAgentImpl(AgentImpl agentObj)
{
-
+
agentObj.setType(Agent.TYPE_DESKTOP);
agentObj.setAgent(Agent.AGENT_EMAIL);
@@ -913,7 +919,7 @@ public class AgentFactoryImpl implements
agentObj.setPlatformVersion(Agent.PLATFORM_VERSION_UNKNOWN);
agentObj.setMakeModel(Agent.MAKE_MODEL_UNKNOWN);
- }
+ }
/**