<%@ page import="oracle.portal.provider.v2.*" %>
<%@ page session="false" import="oracle.portal.provider.v2.render.*" %>
<%@ page import="oracle.portal.provider.v2.http.HttpCommonConstants" %>
<%@ page import="oracle.portal.sample.v2.devguide.cachelevel.resource.CacheLevelBundle" %>
<%@ page import="java.util.ResourceBundle" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.util.Date" %>

<%
  PortletRenderRequest prr = (PortletRenderRequest) request.getAttribute
      (HttpCommonConstants.PORTLET_RENDER_REQUEST);

  // Get non-customizable resource strings.
  Locale locale = prr.getPortletReference().getLocale();
  ResourceBundle bundle =
      prr.getPortletDefinition().getResourceBundle(locale);

  String greetingText      = bundle.getString(CacheLevelBundle.GREETING_KEY);
  String lastAcessText     = bundle.getString(CacheLevelBundle.LASTACCESS_KEY);
  String cacheLevelText    = bundle.getString(CacheLevelBundle.CACHELEVEL_KEY);
  String sessionIDText     = bundle.getString(CacheLevelBundle.SESSIONID_KEY);
  String noSessionIDText   = bundle.getString(CacheLevelBundle.NOSESSIONID_KEY);
  String multSessionIDText = bundle.getString(CacheLevelBundle.MULTSESSIONID_KEY);
  String loginTimeText     = bundle.getString(CacheLevelBundle.LOGINTIME_KEY);
  String noLoginTimeText   = bundle.getString(CacheLevelBundle.NOLOGINTIME_KEY);
  String multLoginTimeText = bundle.getString(CacheLevelBundle.MULTLOGINTIME_KEY);

  String name = prr.getUser().getName(); 
  String date = new Date().toString();

  int cacheLevel = prr.getPortletDefinition().getCacheLevel();

  String cacheLevelStr;

  switch (cacheLevel)
  {
    case PortletConstants.CACHE_LEVEL_SYSTEM:
      cacheLevelStr = PortletConstants.CACHE_LEVEL_SYSTEM_STR;
      break;
    case PortletConstants.CACHE_LEVEL_USER:
      cacheLevelStr = PortletConstants.CACHE_LEVEL_USER_STR;
      break;
    case PortletConstants.CACHE_LEVEL_SESSION:
      cacheLevelStr = PortletConstants.CACHE_LEVEL_SESSION_STR;
      break;
    default:
      cacheLevelStr = "unspecified";
      break;
  }
%>

<H5 ALIGN="CENTER"><%= greetingText%><%= name %></H5>

<H5 ALIGN="CENTER"><%= lastAcessText%><%= date %></H5>

<H5 ALIGN="CENTER"><%= cacheLevelText%><%= cacheLevelStr %></H5>

<%
    String sessionId[] = request.getParameterValues("_sessionid");
    String loginTime[] = request.getParameterValues("_logintime");
%>
    <H5 ALIGN="CENTER">
<%
    
    if (sessionId == null)
    {
%>
      <%= noSessionIDText%>
<%
    }
    else if (sessionId.length > 1)
    {
%>
      <%= multSessionIDText%>
<%
    }
    else
    {
%>
      <%= sessionIDText%><%=sessionId[0]%>. 
<%
    }

    if (loginTime == null)
    {
%>
      <%= noLoginTimeText%>
<%
    }
    else if (loginTime.length > 1)
    {
%>
      <%= multLoginTimeText%>
<%
    }
    else
    {
%>
      <%= loginTimeText%><%=loginTime[0]%>
<%
    }
%>
    </H5>
