private void _populateBaseAgentImpl()

in trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java [167:374]


  private void _populateBaseAgentImpl(
    FacesContext        context,
    Map<String, String> headerMap,
    boolean             noRequest,
    AgentImpl           agent)
  {
    String userAgent = _getUserAgentHeader(headerMap);
    
    if (userAgent == null)
    {
      // This will happen during JSF2 initialization
      _populateUnknownAgentImpl(userAgent, noRequest, agent);
      return;
    }

    boolean isEmailRequest = (context == null) ? false : _showAsEmail(context.getExternalContext());
    
    // rather than test against "true", we test whether the value is 
    if (isEmailRequest)
    {
      _populateEmailAgentImpl(agent);
      return;
    }

    if (userAgent.startsWith("PTG"))
    {
      _populateIaswAgentImpl(userAgent,
                             headerMap.get(_IASW_DEVICE_HINT_PARAM),
                             noRequest,
                             agent);
      return;
    }

    String accept = headerMap.get("Accept");

    // See if the agent wants WML - if so, we're talking WAP.
    if ((accept != null) &&
        accept.regionMatches(true, 0, "vnd.wap.wml", 0, 11))
    {
      _populateWAPAgentImpl(agent);
      return;
    }

    
    // Uncomment if you need to simulate googlebot crawler
    /*if (facesContext != null && facesContext.getExternalContext().getRequestParameterMap().
                        get("googlebot") != null)
    {
      _populateGoogleCrawlerAgentImpl("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)", agent, 25);
      return;
    }*/
    
    int googlebotIndex = userAgent.indexOf(_GOOGLEBOT_ID);
    if (googlebotIndex >= 0)
    {
      _populateCrawlerAgentImpl(userAgent, agent, Agent.AGENT_GOOGLEBOT, _GOOGLEBOT_ID, googlebotIndex);
      return;
    }
    
    int bingIndex = userAgent.indexOf(_BINGBOT_ID);
    if (bingIndex >= 0)
    {
      _populateCrawlerAgentImpl(userAgent, agent, Agent.AGENT_MSNBOT, _BINGBOT_ID, bingIndex);
      return;
    }
    
    bingIndex = userAgent.indexOf(_MSNBOT_ID);
    if (bingIndex >= 0)
    {
      _populateCrawlerAgentImpl(userAgent, agent, Agent.AGENT_MSNBOT, _MSNBOT_ID, bingIndex);
      return;
    }
    
    int oracleSesIndex = userAgent.indexOf(_ORACLE_SES_ID);
    if (oracleSesIndex >= 0)
    {
      _populateCrawlerAgentImpl(userAgent, agent, Agent.AGENT_ORACLE_SES, _ORACLE_SES_ID, oracleSesIndex);
      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
    //because the jdev design time and ITS runtime have access to the same
    //device repository as the Trinidad runtime
    //The PDA DT useragent string will be: OracleJDevMobile/PDA/[agentName]
    //The telnet DT and RT useragent string will be:
    //OracleJDevMobile/ITS/[agentName]
    if (userAgent.startsWith("OracleJDevMobile"))
    {
      _populateJDevMobileAgentImpl(userAgent, noRequest, agent);
      return;
    }
    if (userAgent.startsWith("OracleITS"))
    {
      _populateTelnetAgentImpl(userAgent,agent);
      return;
    }
    if (userAgent.startsWith("Pixo-Browser"))
    {
       _populatePixoAgentImpl(userAgent,agent);
       return;
    }

    if (userAgent.startsWith("ICE Browser"))
    {
       _populateIceAgentImpl(userAgent,agent);
       return;
    }

    // Web Pro
    //userAgent = "Mozilla/4.76 (compatible; MSIE 6.0; U; Windows 95; PalmSource; PalmOS; WebPro; Tungsten Proxyless 1.1 320x320x16)";
    if ( (userAgent.indexOf( "WebPro") != -1 &&
          userAgent.indexOf("Palm")!= -1)||
         userAgent.indexOf("Blazer/3.") != -1)
    {
      _populatePalmWebBrowserProAgentImpl(userAgent,agent);
      return;
    }

    //PPC 02
    //userAgent = "Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; PPC; 240x320)";
    // PPC 03
    //userAgent = "Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)";
    if (userAgent.indexOf("Windows CE") != -1)
    {
      // for PocketPC and Windows Mobile, try to grab the header UA-pixels to
      // determine width/height
      String uaPixels = headerMap.get("UA-pixels");
      _populatePocketPCAgentImpl(userAgent,uaPixels,agent);
      return;
    }

    // This needs to be before check for mozilla!
    if ((userAgent.indexOf("PalmOS") != -1) ||
        (userAgent.indexOf("Blazer") != -1) ||
        (userAgent.indexOf("Xiino") != -1))
    {
      _populatePalmAgentImpl(userAgent,agent);
      return;
    }

    if ((userAgent.indexOf("AppleWebKit") != -1) ||
        (userAgent.indexOf("Safari") != -1))
    {
      _populateSafariAgentImpl(userAgent,agent);
      return;
    }

    if(userAgent.startsWith("BlackBerry"))
    {
        _populateBlackberryAgentImpl(userAgent,agent);
        return;
    }

    if (userAgent.indexOf("Opera") > -1)
    {
        _populateOperaAgentImpl(userAgent,agent);
        return;
    }

    // Generic Mobile Browser Detection
    // The user agent signature varies depending on the
    // device manufacturer and carrier. Use case insensitive
    // string matching.
    // Some of the browsers listed below support higher capabilities
    // than basic HTML browser capabilities. However, those browsers
    // are treated as basic HTML browser here for maximam compatibility
    // and performance.
    // We do not support WAP1.X browsers (WML).

    String userAgentLowercase = userAgent.toLowerCase();

    if ((userAgentLowercase.indexOf("wap1.") < 0) &&
        (userAgentLowercase.indexOf("wap2.") > -1  ||
         userAgentLowercase.indexOf("up.browser") > -1 ||
         userAgentLowercase.indexOf("nokia") > -1 ||
         userAgentLowercase.startsWith("mot-") ||
         userAgentLowercase.indexOf("symbian") > -1 ||
         userAgentLowercase.indexOf("sonyeri") > -1 ||
         userAgentLowercase.indexOf("netfront/") > -1 ||
         userAgentLowercase.startsWith("samsang-") ||
         userAgentLowercase.startsWith("lg-") ||
         userAgentLowercase.indexOf("obigo") > -1||
         userAgentLowercase.indexOf("vodafone") > -1 ||
         userAgentLowercase.indexOf("kddi") > -1 ||
         userAgentLowercase.indexOf("openwave") > -1))
    {
      _populateGenericPDAAgentImpl(agent);
      return;
    }

    // Gecko and Mozilla tests should be placed following more specific
    // uiser-agent test.
    if (userAgent.indexOf("Gecko/") != -1)
    {
      _populateGeckoAgentImpl(userAgent,agent);
      return;
    }
    // must check for gecko before checking for mozilla:
    else if (userAgent.startsWith("Mozilla"))
    {
      _populateMozillaAgentImpl(userAgent,agent);
      return;
    }

    _populateUnknownAgentImpl(userAgent, noRequest, agent);
  }