<%@ include file = "EgMonitorTracker.jsp" %>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import = "net.sf.json.*" %>
<%@ page import = "java.util.*"%>
<%@ page import = "java.text.*" %>
<%@ page import = "java.io.*" %>
<%@ page import = "com.egurkha.RUMHelper"%>
<%@ page import = "com.egurkha.BTMHelper"%>
<%@ page import = "com.egurkha.util.StringUtils"%>
<%@ page import = "com.egurkha.util.DateUtil"%>
<%@ page import = "com.eg.*" %>
<%@ page import = "com.fasterxml.jackson.databind.*" %>
<%@ page import = "com.fasterxml.jackson.core.*" %>
<%@ page import = "com.fasterxml.jackson.databind.node.*" %>
<%@ page import = "com.eg.EgDbaseInfo"%>
<%
	response.setContentType("text/html;charset=UTF-8");
	String comesFrom = request.getParameter("comesFrom");
	
	if(comesFrom!=null && comesFrom.equalsIgnoreCase("mydashboard"))
	{
		String myDashboardTheme = request.getParameter("myDashboardTheme");
		if(!StringUtils.isNull(myDashboardTheme) && !myDashboardTheme.equalsIgnoreCase(monitor_Skin))
		{
			monitor_Skin=myDashboardTheme;
		}
	}
%>

<%!
	DecimalFormat percentFormat = new DecimalFormat("#.##");
	EgAPMInfo apm = new EgAPMInfo("manager");
	
	private String name = "USER_NAME";
	private String guid = "GUID";
	private String country = "COUNTRY";
	private String region = "REGION";
	private String countryCode = "COUNTRY_CODE";
	private String city = "CITY";
	private String rumUserExp = "RUM_USER_EXP";
	private String rumUserExpKey = "RUM_USER_EXPERIENCE";
	private String requestDate = "REQUEST_DATE";
	private String url = "URL";
	private String urlParams = "URL_PARAMS";
	private String pagetype = "PAGETYPE";
	private String referrer = "REFERRER";
	private String ip = "IP";
	private String gatewayIp = "GATEWAY_IP";
	private String device = "DEVICE";
	private String os = "OS";
	private String errorMessage = "ERROR_MESSAGE";
	private String errorMsgCount = "ERROR_MSG_COUNT";
	private String requestTimeZone = "REQUEST_TIME_ZONE";
	private String sessionid = "SESSIONID";
	private String slowUrlThreshold = "SLOW_URL_THRESHOLD";
	private String browserName = "BROWSER";
	private String browserNameKey = "NAME";
	private String browserVersion = "BROWSER_VERSION";
	private String browserVersionKey = "VERSION";
	private String pageLoadTime = "PAGE_LOAD_TIME";
	private String frontEndTime = "FRONT_END_TIME";
	private String firstByteTime = "FIRST_BYTE_TIME";
	private String pageRenderTime = "PAGE_RENDER_TIME";
	private String documentReadyTime = "DOCUMENT_READY_TIME";
	private String documentDownloadTime = "DOCUMENT_DOWNLOAD_TIME";
	private String documentProcessingTime = "DOCUMENT_PROCESSING_TIME";
	private String serverConnectionTime = "SERVER_CONNECTION_TIME";
	private String dnsLookupTime = "DNSLOOKUPTIME";
	private String tcpConnectTime = "TCPCONNECTTIME";
	private String responseAvailableTime = "RESPONSE_AVAILABLE_TIME";
	private String redirectOrAppCacheKey = "REDIRECT_OR_APPCACHE";
	// Added for Resource Details Page
	private String documentContentLoaded = "DOCUMENT_CONTENT_LOADED";
	private String browserPercentageKey = "BROWSER_PERCENTAGE";
	private String networkPercentageKey = "NETWORK_PERCENTAGE";
	private String backendPercentageKey = "BACKEND_PERCENTAGE";
	private String contentDownloadPercentageKey = "CONTENT_DOWNLOAD_PERCENTAGE";
	private String resourceDetailsNotFound = "RESOURCE_DETAILS_NOT_FOUND";
	private String valueKey = "value";
	private String legendKey = "legend";
	private String colorKey = "color";
	private String browserColor_Light = "#409fb4";
	private String networkColor_Light = "#24384b";
	private String backendColor_Light = "#f1be5c";
	private String contentDwnlColor_Light = "#e57e73";

	private String browserColor_Dark = "#d6b088";
	private String networkColor_Dark = "#7c9ac9";
	private String backendColor_Dark = "#c998b4";
	private String contentDwnlColor_Dark = "#8f8483";
	
	private String browserWaitTime = "BROWSER_WAIT_TIME";
	private String redirectionTime_txt = "REDIRECTION_TIME";
	private String appCacheTime = "APP_CACHE_TIME";
	private String sslHandshakeTime = "SSL_HANDSHAKE_TIME";
	
	private String waitBeforeRedirectTime = "WAIT_BEFORE_REDIRECT_TIME";
	private String waitAfterRedirectTime = "WAIT_AFTER_REDIRECT_TIME";
	private String waitStartFetchTime = "WAIT_START_FETCH_TIME";
	private String blockWaitBeforeRedirect = "BLOCK_WAIT_BEFORE_REDIRECT";
	private String redirectDuration = "REDIRECT_DURATION";
	private String blockWaitAfterRedirect = "BLOCK_WAIT_AFTER_REDIRECT";
	private String blockWaitBeforeAppCache = "BLOCK_WAIT_BEFORE_APPCACHE";
	private String relativeAppCacheDuration = "RELATIVE_APPCACHE_DURATION";
	private String dnsDuration = "DNS_DURATION";
	private String blockWaitBeforeTCP = "BLOCK_WAIT_BEFORE_TCP";
	private String tcpConnectDuration = "TCP_CONNECT_DURATION";
	private String sslConnectDuration = "SSL_CONNECT_DURATION";
	private String blockWaitBeforeRequest = "BLOCK_WAIT_BEFORE_REQUEST";
	private String serverProcessingDuration = "SERVER_PROCESSING_DURATION";
	private String contentDownloadDuration = "CONTENT_DOWNLOAD_DURATION";
	private String waitBeforeConnectTime = "WAIT_BEFORE_CONNECT_TIME";
	private String waitBeforeRequestTime = "WAIT_BEFORE_REQUEST_TIME";
	
	private String btmGuid = "BTM_GUID";
	private String btmNodeOrder = "BTM_NODE_ORDER";
	private String btmTopologyUrl = "BTM_TOPOLOGY_URL";
	
	private String networkConnectionTime = "NETWORK_CONNECTION_TIME";
	private String browserTime_key = "BROWSER_TIME";
	private String resourceFetchRenderingTime = "RESOURCE_FETCH_RENDERING_TIME";
	private String request="REQUEST";
	private String response="RESPONSE";
	private String serverTime_txt = "SERVER_TIME";
	private String URLParameters = "URL_PARAMETERS";
	private String requestfor = "REQUEST_FOR";
	private String at = "AT";
	private String rumTransactionDetails = "RUM_TRANSACTION_DETAILS";
	private String resourceDetails = "RESOURCE_DETAILS";
	private String back = "BACK";
	private String htmlDownloadTime = "HTML_DOWNLOAD_TIME";
	private String ajaxCallBackTime = "AJAX_CALL_BACK_TIME";
	private String ajaxCall = "AJAX_CALL";
	private String contentDownloadTime_txt = "CONTENT_DOWNLOAD_TIME";
	private String breakupPageLoadTime = "BREAKUP_OF_PAGE_LOAD_TIME";
	private String noDataFound = "NO_DATA_FOUND";
	private String location = "LOCATION";
	private String ajaxCallBackTime_ms = "AJAX_CALLBACK_TIME_MS";
	private String browserTime_ms = "BROWSER_TIME_MS";
	private String call = "CALL";
	private String resourceDownload = "RESOURCE_DOWNLOAD";
	private String networkConnecionBreakUp = "NETWORK_CONNECTION_BREAK_UP";
	private String requests="REQUESTS";
	private String transferred = "TRANSFERRED";
	private String clientInformation = "CLIENT_INFORMATION";
	private String resources = "RESOURCES";
	private String domain = "DOMAIN";
	private String type = "TYPE";
	private String relativeStartTime = "RELATIVE_START_TIME";
	private String duration = "DURATION";
	private String splitOfDuration = "SPLIT_OF_DURATION";
	private String actualWork = "ACTUAL_WORK";
	private String block_wait = "BLOCK_WAIT";
	private String transferSize = "TRANSFER_SIZE";
	private String resourceName = "RESOURCE_NAME";
	private String actualWorkTime_txt = "ACTUAL_WORK_TIME";
	private String blockTime = "BLOCk_WAIT_TIME";
	private String percTimeSplit = "PERCENTAGE_TIME_SPLIT";
	private String browserNavgationFlow = "BROWSER_NAVIGATION_FLOW";
	private String browserNotSupport = "BROWSER_NOT_SUPPORT";
	private String browserNotSupportResourceAPI = "BROWSER_NOT_SUPPORT_RESOURCE_API";
	private String forAJAXRequest = "FOR_AJAX_REQUEST";
	private String millisecond = "MILLISEC";
	private String error = "ERROR";
	private String on = "ON";
	private String pageTypeName = "";
	
	
	public long getLongVal(ArrayNode res_list,int index){
		long time = 0;
		try
		{
			String el = ""+res_list.get(index);
			time = Long.valueOf(el);
		}
		catch(Exception ee)
		{
			time = 0;
		}
		return time;
	}

	public String getFileSize(long size, String sizeType) {
		DecimalFormat format = new DecimalFormat("#.##");
		double MiB = 1024 * 1024;
		double KiB = 1024;
		double sizeByte = (double)size;
		if(sizeType == null){
			if (sizeByte > MiB) {
				return format.format(sizeByte / MiB)+" MB";
			}
			if (sizeByte > KiB) {
				return format.format(sizeByte / KiB) + " KB";
			}
			return format.format(sizeByte) + " B";
		}

		if(sizeType.equalsIgnoreCase("mb")){
			return format.format(sizeByte / MiB);
		}

		if(sizeType.equalsIgnoreCase("kb")){
			return format.format(sizeByte / KiB);
		}
		return format.format(sizeByte);
	}
	public JSONObject rumJsonBuild(String monitor_Skin, Hashtable rumDataTable,  EgMappingInfo mappingInfo, Hashtable rumResourceDataTable,User user){

		String lbl_Name = mappingInfo.getTextDescription("monitor.rumtopology.USER_NAME");
		String lbl_Guid = mappingInfo.getTextDescription("monitor.rumtopology.GUID");
		String lbl_Country = mappingInfo.getTextDescription("monitor.rumtopology.COUNTRY");
		String lbl_Region = mappingInfo.getTextDescription("monitor.rumtopology.REGION");
		String lbl_CountryCode = mappingInfo.getTextDescription("monitor.rumtopology.COUNTRY_CODE");
		String lbl_City = mappingInfo.getTextDescription("monitor.rumtopology.CITY");
		String lbl_RumUserExp = mappingInfo.getTextDescription("monitor.rumtopology.RUM_USER_EXP");
		String lbl_RumUserExpKey = mappingInfo.getTextDescription("monitor.rumtopology.RUM_USER_EXPERIENCE");
		String lbl_RequestDate = mappingInfo.getTextDescription("monitor.rumtopology.REQUEST_DATE");
		String lbl_Url = mappingInfo.getTextDescription("monitor.rumtopology.URL");
		String lbl_Pagetype = mappingInfo.getTextDescription("monitor.rumtopology.PAGETYPE");
		String lbl_Referrer = mappingInfo.getTextDescription("monitor.rumtopology.REFERRER");
		String lbl_Ip = mappingInfo.getTextDescription("monitor.rumtopology.IP");
		String lbl_GatewayIp = mappingInfo.getTextDescription("monitor.rumtopology.GATEWAY_IP");
		String lbl_Device = mappingInfo.getTextDescription("monitor.rumtopology.DEVICE");
		String lbl_Os = mappingInfo.getTextDescription("monitor.rumtopology.OS");
		String lbl_ErrorMessage = mappingInfo.getTextDescription("monitor.rumtopology.ERROR_MESSAGE");
		String lbl_RequestTimeZone = mappingInfo.getTextDescription("monitor.rumtopology.REQUEST_TIME_ZONE");
		String lbl_Sessionid = mappingInfo.getTextDescription("monitor.rumtopology.SESSIONID");
		String lbl_SlowUrlThreshold = mappingInfo.getTextDescription("monitor.rumtopology.SLOW_URL_THRESHOLD");
		String lbl_BrowserName = mappingInfo.getTextDescription("monitor.rumtopology.BROWSER");
		String lbl_BrowserNameKey = mappingInfo.getTextDescription("monitor.rumtopology.NAME");
		String lbl_BrowserVersion = mappingInfo.getTextDescription("monitor.rumtopology.BROWSER_VERSION");
		String lbl_BrowserVersionKey = mappingInfo.getTextDescription("monitor.rumtopology.VERSION");
		String lbl_PageLoadTime = mappingInfo.getTextDescription("monitor.rumtopology.PAGE_LOAD_TIME");
		String lbl_FrontEndTime = mappingInfo.getTextDescription("monitor.rumtopology.FRONT_END_TIME");
		String lbl_PageRenderTime = mappingInfo.getTextDescription("monitor.rumtopology.PAGE_RENDER_TIME");
		String lbl_DocumentReadyTime = mappingInfo.getTextDescription("monitor.rumtopology.DOCUMENT_READY_TIME");
		String lbl_DocumentDownloadTime = mappingInfo.getTextDescription("monitor.rumtopology.DOCUMENT_DOWNLOAD_TIME");
		String lbl_DocumentProcessingTime = mappingInfo.getTextDescription("monitor.rumtopology.DOCUMENT_PROCESSING_TIME");
		String lbl_ServerConnectionTime = mappingInfo.getTextDescription("monitor.rumtopology.SERVER_CONNECTION_TIME");
		String lbl_DnsLookupTime = mappingInfo.getTextDescription("monitor.rumtopology.DNSLOOKUPTIME");
		String lbl_TcpConnectTime = mappingInfo.getTextDescription("monitor.rumtopology.TCPCONNECTTIME");
		String lbl_ResponseAvailableTime = mappingInfo.getTextDescription("monitor.rumtopology.RESPONSE_AVAILABLE_TIME");
		String lbl_RedirectOrAppCacheKey = mappingInfo.getTextDescription("monitor.rumtopology.REDIRECT_OR_APPCACHE");
		String lbl_BrowserPercentageKey = mappingInfo.getTextDescription("monitor.rumtopology.BROWSER_PERCENTAGE");
		String lbl_NetworkPercentageKey = mappingInfo.getTextDescription("monitor.rumtopology.NETWORK_PERCENTAGE");
		String lbl_BackendPercentageKey = mappingInfo.getTextDescription("monitor.rumtopology.BACKEND_PERCENTAGE");
		String lbl_ContentDownloadPercentageKey = mappingInfo.getTextDescription("monitor.rumtopology.CONTENT_DOWNLOAD_PERCENTAGE");
		String lbl_documentContentLoaded = mappingInfo.getTextDescription("monitor.rumtopology.DOCUMENT_CONTENT_LOADED");
		
		
		String lbl_browserWaitTime = mappingInfo.getTextDescription("monitor.rumtopology.BROWSER_WAIT_TIME");
		String lbl_appCacheTime = mappingInfo.getTextDescription("monitor.rumtopology.APP_CACHE_TIME");
		String lbl_sslHandshakeTime = mappingInfo.getTextDescription("monitor.rumtopology.SSL_HANDSHAKE_TIME");
	
		String lbl_notApplicable = mappingInfo.getTextDescription("monitor.rumtopology.NOT_APPLICABLE");
		String lbl_notAvailable = mappingInfo.getTextDescription("monitor.rumtopology.NOT_AVAILABLE");

		String lbl_WAIT_BEFORE_REDIRECT_TIME= mappingInfo.getTextDescription("monitor.rumtopology.WAIT_BEFORE_REDIRECT_TIME");
		String lbl_REDIRECTION_TIME= mappingInfo.getTextDescription("monitor.rumtopology.REDIRECTION_TIME");
		String lbl_WAIT_AFTER_REDIRECT_TIME= mappingInfo.getTextDescription("monitor.rumtopology.WAIT_AFTER_REDIRECT_TIME");
		String lbl_WAIT_START_FETCH_TIME= mappingInfo.getTextDescription("monitor.rumtopology.WAIT_START_FETCH_TIME");
		String lbl_BLOCK_WAIT_BEFORE_REDIRECT= mappingInfo.getTextDescription("monitor.rumtopology.BLOCK_WAIT_BEFORE_REDIRECT");
		String lbl_REDIRECT_DURATION= mappingInfo.getTextDescription("monitor.rumtopology.REDIRECT_DURATION");
		String lbl_BLOCK_WAIT_AFTER_REDIRECT= mappingInfo.getTextDescription("monitor.rumtopology.BLOCK_WAIT_AFTER_REDIRECT");
		String lbl_BLOCK_WAIT_BEFORE_APPCACHE= mappingInfo.getTextDescription("monitor.rumtopology.BLOCK_WAIT_BEFORE_APPCACHE");
		String lbl_RELATIVE_APPCACHE_DURATION= mappingInfo.getTextDescription("monitor.rumtopology.RELATIVE_APPCACHE_DURATION");
		String lbl_DNS_DURATION= mappingInfo.getTextDescription("monitor.rumtopology.DNS_DURATION");
		String lbl_BLOCK_WAIT_BEFORE_TCP= mappingInfo.getTextDescription("monitor.rumtopology.BLOCK_WAIT_BEFORE_TCP");
		String lbl_TCP_CONNECT_DURATION= mappingInfo.getTextDescription("monitor.rumtopology.TCP_CONNECT_DURATION");
		String lbl_SSL_CONNECT_DURATION= mappingInfo.getTextDescription("monitor.rumtopology.SSL_CONNECT_DURATION");
		String lbl_BLOCK_WAIT_BEFORE_REQUEST= mappingInfo.getTextDescription("monitor.rumtopology.BLOCK_WAIT_BEFORE_REQUEST");
		String lbl_SERVER_PROCESSING_DURATION= mappingInfo.getTextDescription("monitor.rumtopology.SERVER_PROCESSING_DURATION");
		String lbl_CONTENT_DOWNLOAD_DURATION= mappingInfo.getTextDescription("monitor.rumtopology.CONTENT_DOWNLOAD_DURATION");
		String lbl_WAIT_BEFORE_CONNECT_TIME= mappingInfo.getTextDescription("monitor.rumtopology.WAIT_BEFORE_CONNECT_TIME");
		String lbl_WAIT_BEFORE_REQUEST_TIME = mappingInfo.getTextDescription("monitor.rumtopology.WAIT_BEFORE_REQUEST_TIME");
		
		String lbl_RESOURCE_DETAILS_NOT_FOUND = mappingInfo.getTextDescription("monitor.rumtopology.RESOURCE_DETAILS_NOT_FOUND");
		
		String lbl_HTML_DOWNLOAD_TIME = mappingInfo.getTextDescription("monitor.rumtopology.HTML_DOWNLOAD_TIME");
		
		
		String lbl_NETWORK_CONNECTION_TIME = mappingInfo.getTextDescription("monitor.rumtopology.NETWORK_CONNECTION_TIME");
		String lbl_BROWSER_TIME = mappingInfo.getTextDescription("monitor.rumtopology.BROWSER_TIME");
		String lbl_RESOURCE_FETCH_RENDERING_TIME = mappingInfo.getTextDescription("monitor.rumtopology.RESOURCE_FETCH_RENDERING_TIME");
		String lbl_REQUEST = mappingInfo.getTextDescription("monitor.rumtopology.REQUEST");
		String lbl_RESPONSE = mappingInfo.getTextDescription("monitor.rumtopology.RESPONSE");
		String lbl_SERVER_TIME = mappingInfo.getTextDescription("monitor.rumtopology.SERVER_TIME");
		String lbl_URL_PARAMETERS = mappingInfo.getTextDescription("monitor.rumtopology.URL_PARAMETERS");
		String lbl_REQUEST_FOR = mappingInfo.getTextDescription("monitor.rumtopology.REQUEST_FOR");
		String lbl_AT = mappingInfo.getTextDescription("monitor.rumtopology.AT");
		String lbl_RUM_TRANSACTION_DETAILS = mappingInfo.getTextDescription("monitor.rumtopology.RUM_TRANSACTION_DETAILS");
		String lbl_RESOURCE_DETAILS = mappingInfo.getTextDescription("monitor.rumtopology.RESOURCE_DETAILS");
		String lbl_BACK = mappingInfo.getTextDescription("monitor.rumtopology.BACK");
		String lbl_AJAX_CALL_BACK_TIME = mappingInfo.getTextDescription("monitor.rumtopology.AJAX_CALL_BACK_TIME");
		String lbl_AJAX_CALL = mappingInfo.getTextDescription("monitor.rumtopology.AJAX_CALL");
		String lbl_CONTENT_DOWNLOAD_TIME = mappingInfo.getTextDescription("monitor.rumtopology.CONTENT_DOWNLOAD_TIME");
		String lbl_BREAKUP_OF_PAGE_LOAD_TIME = mappingInfo.getTextDescription("monitor.rumtopology.BREAKUP_OF_PAGE_LOAD_TIME");
		
		
		String lbl_REQUESTS = mappingInfo.getTextDescription("monitor.rumtopology.REQUESTS");
		String lbl_TRANSFERRED = mappingInfo.getTextDescription("monitor.rumtopology.TRANSFERRED");
		String lbl_CLIENT_INFORMATION = mappingInfo.getTextDescription("monitor.rumtopology.CLIENT_INFORMATION");
		String lbl_RESOURCES = mappingInfo.getTextDescription("monitor.rumtopology.RESOURCES");
		String lbl_DOMAIN = mappingInfo.getTextDescription("monitor.rumtopology.DOMAIN");
		String lbl_TYPE = mappingInfo.getTextDescription("monitor.rumtopology.TYPE");
		String lbl_RELATIVE_START_TIME = mappingInfo.getTextDescription("monitor.rumtopology.RELATIVE_START_TIME");
		String lbl_DURATION = mappingInfo.getTextDescription("monitor.rumtopology.DURATION");
		String lbl_SPLIT_OF_DURATION = mappingInfo.getTextDescription("monitor.rumtopology.SPLIT_OF_DURATION");
		String lbl_ACTUAL_WORK = mappingInfo.getTextDescription("monitor.rumtopology.ACTUAL_WORK");
		String lbl_BLOCK_WAIT = mappingInfo.getTextDescription("monitor.rumtopology.BLOCk_WAIT");
		String lbl_TRANSFER_SIZE = mappingInfo.getTextDescription("monitor.rumtopology.TRANSFER_SIZE");
		
		String lbl_RESOURCE_NAME = mappingInfo.getTextDescription("monitor.rumtopology.RESOURCE_NAME");
		String lbl_ACTUAL_WORK_TIME = mappingInfo.getTextDescription("monitor.rumtopology.ACTUAL_WORK_TIME");
		String lbl_BLOCk_WAIT_TIME = mappingInfo.getTextDescription("monitor.rumtopology.BLOCk_WAIT_TIME");
		String lbl_PERCENTAGE_TIME_SPLIT = mappingInfo.getTextDescription("monitor.rumtopology.PERCENTAGE_TIME_SPLIT");
		String lbl_BROWSER_NAVIGATION_FLOW = mappingInfo.getTextDescription("monitor.rumtopology.BROWSER_NAVIGATION_FLOW");
		String lbl_BROWSER_NOT_SUPPORT = mappingInfo.getTextDescription("monitor.rumtopology.BROWSER_NOT_SUPPORT");
		String lbl_BROWSER_NOT_SUPPORT_RESOURCE_API = mappingInfo.getTextDescription("monitor.rumtopology.BROWSER_NOT_SUPPORT_RESOURCE_API");
		String lbl_FOR_AJAX_REQUEST = mappingInfo.getTextDescription("monitor.rumtopology.FOR_AJAX_REQUEST");
		String lbl_NO_DATA_FOUND = mappingInfo.getTextDescription("monitor.rumtopology.NO_DATA_FOUND");
		String lbl_LOCATION = mappingInfo.getTextDescription("monitor.rumtopology.LOCATION");
		String lbl_AJAX_CALLBACK_TIME_MS = mappingInfo.getTextDescription("monitor.rumtopology.AJAX_CALLBACK_TIME_MS");
		String lbl_BROWSER_TIME_MS = mappingInfo.getTextDescription("monitor.rumtopology.BROWSER_TIME_MS");
		String lbl_CALL = mappingInfo.getTextDescription("monitor.rumtopology.CALL");
		String lbl_RESOURCE_DOWNLOAD = mappingInfo.getTextDescription("monitor.rumtopology.RESOURCE_DOWNLOAD");
		String lbl_NETWORK_CONNECTION_BREAK_UP = mappingInfo.getTextDescription("monitor.rumtopology.NETWORK_CONNECTION_BREAK_UP");
		String lbl_MILLISEC = mappingInfo.getTextDescription("monitor.rumtopology.MILLISEC");
		String lbl_ERROR = mappingInfo.getTextDescription("monitor.rumtopology.ERROR");
		String lbl_ON = mappingInfo.getTextDescription("monitor.rumtopology.ON");
    
		pageTypeName = (String)rumDataTable.get(pagetype);
		if(pageTypeName != null && pageTypeName.equalsIgnoreCase("AJAX")){
			double tcpTimeAjax = Double.parseDouble((String)rumDataTable.get(tcpConnectTime));
			if(tcpTimeAjax != -5){
				pageTypeName = "AjaxPage";
				rumDataTable.put(pagetype, pageTypeName);
			}
			lbl_RESOURCE_DETAILS_NOT_FOUND = mappingInfo.getTextDescription("monitor.rumtopology.AJAX_RESOURCE_DETAILS_NOT_FOUND");
		}
		JSONObject resourceTextObj = new JSONObject();
		resourceTextObj.put(resourceDetailsNotFound, lbl_RESOURCE_DETAILS_NOT_FOUND);

		JSONObject rootJson = new JSONObject();
		rootJson.put("resourceText", resourceTextObj);
		JSONObject allJson = new JSONObject();
		JSONObject userJson = new JSONObject();
		JSONObject networkJson = new JSONObject();
		JSONObject backendJson = new JSONObject();
		JSONObject contentDownloadJson = new JSONObject();
		JSONObject browserJson = new JSONObject();
		JSONObject headerJson = new JSONObject();
		JSONObject otherJson = new JSONObject();
		JSONObject browserObj = new JSONObject();
		JSONObject networkObj = new JSONObject();
		JSONObject backendObj = new JSONObject();
		JSONObject contentDwlObj = new JSONObject();
		JSONObject mappingNameObj = new JSONObject();
		JSONArray pieCharArray = new JSONArray();
		JSONArray gridData = new JSONArray();
		
		EgDbaseInfo egDbaseInfo = new EgDbaseInfo("manager");
		String btmGuidValue = (String)rumDataTable.get(btmGuid);
		String btmNodeOrderValue = (String)rumDataTable.get(btmNodeOrder);
		String btmExpQueryresult = BTMHelper.getBTMExpQuery(btmGuidValue);

		ArrayList btmTestDetailsForRequest = BTMHelper.getTestDetailsForRequest(btmExpQueryresult);
		/*
			btmNodeOrderValue contains special symbol . Tomcat rejects the special symbols in query param So we have to encode the value to provide in query string 
		*/
		btmNodeOrderValue = StringUtils.encodeSecurityChar(btmNodeOrderValue);
		btmNodeOrderValue = BTMHelper.getEncodedURI(btmNodeOrderValue);

		
		String btmUrl = "";
		if(btmTestDetailsForRequest != null && btmTestDetailsForRequest.size()>0)
		{
			ArrayList btmTestDetails = (ArrayList) btmTestDetailsForRequest.get(1);
			if(btmTestDetails!=null && btmTestDetails.size() > 0){
				String testName = (String)btmTestDetails.get(0);
				if(testName!=null && testName.endsWith("_DDD")){
					testName = testName.substring(0, testName.lastIndexOf("_DDD"));
				}
				String btmQuery = BTMHelper.topologyQuery(btmGuidValue, egDbaseInfo, btmTestDetails);
				if(btmQuery != null && btmQuery.length() > 0){
					boolean btmResultSet = BTMHelper.getRequestMapDetails(btmQuery);
					if(btmResultSet){
						btmUrl = "/final/monitor/eGBTMd3Topology.jsp?testName="+testName+"&EG_GUID="+btmGuidValue+"&fromNodeOrder="+btmNodeOrderValue;
					}
				}
			}
		}

		JSONObject resourceSizeObj = new JSONObject();
		if(rumResourceDataTable != null && rumResourceDataTable.size() > 0)
		{
			long totalEncodedBodySize = 0;
			long totalDecodedBodySize = 0;
			long totalTransferSize = 0;
			for(int m = 0; m <= rumResourceDataTable.size()-1; m++)
			{
				String key = "resource"+m;
				ArrayList resourceList = (ArrayList) rumResourceDataTable.get(key);
				JSONArray detailsArray = new JSONArray();
				JSONObject detailsObj = null;
				if(resourceList != null && resourceList.size()>0)
				{
					JSONObject tmpObj = new JSONObject();
					tmpObj.put("S_No", m+1);
					
					String resourcePath = resourceList.get(0).toString();
					if(resourcePath.equals("/")){
						resourcePath = resourceList.get(1).toString();
					}
					tmpObj.put("Resource_Name", resourcePath);
					tmpObj.put("Resource_Domain",resourceList.get(1));
					tmpObj.put("Resource_Type",resourceList.get(2));
					//tmpObj.put("Resource_Time",resourceList.get(3));
					double rescTime = Double.valueOf(resourceList.get(3).toString());
					tmpObj.put("Resource_Time", (long)rescTime);
					
					String initiatorType = resourceList.get(4).toString();					

					tmpObj.put("initiator_type", initiatorType.toUpperCase());

					long offset = Long.valueOf(resourceList.get(5).toString());
					int format = Integer.valueOf(resourceList.get(6).toString());
					

					long encodedBodySize = Long.valueOf(resourceList.get(9).toString());
					long decodedBodySize = Long.valueOf(resourceList.get(10).toString());
					long transferSize = Long.valueOf(resourceList.get(11).toString());
					
					if(transferSize < 0){
						tmpObj.put("transfer_size", "-");
					}
					else{
						tmpObj.put("transfer_size", getFileSize(transferSize, "kb"));
					}

					if(encodedBodySize > -1){
						totalEncodedBodySize = totalEncodedBodySize + encodedBodySize;
					}
					
					if(decodedBodySize > -1){
						totalDecodedBodySize = totalDecodedBodySize + decodedBodySize;
					}

					if(transferSize > -1){
						totalTransferSize = totalTransferSize + transferSize;
					}
					
					
					String nextHopProtocol = resourceList.get(12).toString();
					long redirectCount = Long.valueOf(resourceList.get(13).toString());
					double workerStart = 0.0;
					try
					{
						workerStart = Double.valueOf(resourceList.get(14).toString());
					}
					catch (Exception er)
					{
					}
					tmpObj.put("nexthop_protocol", nextHopProtocol);

					String navType = resourceList.get(15).toString();
					String entryType = resourceList.get(16).toString();
					// String urlFull = resourceList.get(17).toString();
					tmpObj.put("Resource_Nav_Type", navType.toUpperCase());
					tmpObj.put("Resource_Entry_Type", entryType.toUpperCase());
					tmpObj.put("Resource_offset", offset);
					
					try
					{
						if(format == 1)
						{
							ArrayNode res_list = (ArrayNode) resourceList.get(7);
							long startTime = getLongVal(res_list,0) > -1 ? (offset + getLongVal(res_list,0) ) : 0;
							long redirectStart = getLongVal(res_list,1) > -1 ? ( offset + getLongVal(res_list,1)) : 0 ;
							long redirectEnd = getLongVal(res_list,2) > -1 ? ( offset + getLongVal(res_list,2)) : 0 ;
							long fetchStart = getLongVal(res_list,3) > -1 ? ( offset + getLongVal(res_list,3)) : 0 ;
							long domainLookupStart = getLongVal(res_list,4) > -1 ? ( offset + getLongVal(res_list,4)) : 0 ;
							long domainLookupEnd = getLongVal(res_list,5) > -1 ? ( offset + getLongVal(res_list,5)) : 0 ;
							long connectStart = getLongVal(res_list,6) > -1 ? ( offset + getLongVal(res_list,6)) : 0 ;
							long connectEnd = getLongVal(res_list,7) > -1 ? ( offset + getLongVal(res_list,7)) : 0 ;
							long requestStart = getLongVal(res_list,8) > -1 ? ( offset + getLongVal(res_list,8)) : 0 ;
							long responseStart = getLongVal(res_list,9) > -1 ? ( offset + getLongVal(res_list,9)) : 0 ;
							long responseEnd = getLongVal(res_list,10) > -1 ? ( offset + getLongVal(res_list,10)) : 0 ;
							
							double sslTimeDouble = Double.valueOf(resourceList.get(8).toString());
							long sslTime = (long) sslTimeDouble;
							
							// Issue in Resource API for Resource URL Directed Timings. Need to fix like Navigation API.
							
							long totalBlockWaitTime = 0;
							long waitAfterRedirection = 0;
							long waitBeforeRedirection = 0;
							long waitStartToFetch=0;
							long redirectionTime = redirectEnd - redirectStart;
							if(redirectionTime > 0){
								waitBeforeRedirection = redirectStart - startTime;
								waitAfterRedirection = fetchStart - redirectEnd;
								totalBlockWaitTime = waitBeforeRedirection + waitAfterRedirection;
							}
							else{
								waitStartToFetch = fetchStart - startTime;
								totalBlockWaitTime = waitStartToFetch;
							}
							
							long appCache = domainLookupStart - fetchStart;
							long dnsTime = domainLookupEnd - domainLookupStart;
							long waitBeforeConnect = connectStart - domainLookupEnd;
							long connectTime = connectEnd - connectStart;

							if(sslTime > 0){
									connectTime = connectTime - sslTime;
							}
							
							long waitBeforeRequest = requestStart - connectEnd;
							long serverTime = responseStart - requestStart;
							long contentDownloadTime = responseEnd - responseStart;
							
							totalBlockWaitTime =  totalBlockWaitTime + waitBeforeConnect + waitBeforeRequest;
							long actualWorkTime = redirectionTime + appCache + dnsTime + connectTime + sslTime + serverTime + contentDownloadTime;
							
							tmpObj.put("total_block_wait_time", totalBlockWaitTime);
							
							if(redirectCount > 0){ 
								tmpObj.put(waitBeforeRedirectTime, waitBeforeConnect);	
								tmpObj.put(waitAfterRedirectTime, waitAfterRedirection);
								tmpObj.put(waitStartFetchTime, lbl_notApplicable);

								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_WAIT_BEFORE_REDIRECT_TIME);
								detailsObj.put("duration",waitBeforeConnect);
								detailsArray.add(detailsObj);
								
								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_REDIRECTION_TIME);
								detailsObj.put("duration",redirectionTime);
								detailsArray.add(detailsObj);
								
								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_WAIT_AFTER_REDIRECT_TIME);
								detailsObj.put("duration",waitAfterRedirection);
								detailsArray.add(detailsObj);

								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_WAIT_START_FETCH_TIME);
								detailsObj.put("duration",lbl_notApplicable);
								detailsArray.add(detailsObj);
								
							}else{
								tmpObj.put(waitBeforeRedirectTime, lbl_notApplicable);	
								tmpObj.put(waitAfterRedirectTime, lbl_notApplicable);
								tmpObj.put(waitStartFetchTime, waitStartToFetch);

								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_BLOCK_WAIT_BEFORE_REDIRECT);
								detailsObj.put("duration",lbl_notApplicable);
								detailsArray.add(detailsObj);

								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_REDIRECT_DURATION);
								detailsObj.put("duration",lbl_notApplicable);
								detailsArray.add(detailsObj);
								
								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_BLOCK_WAIT_AFTER_REDIRECT);
								detailsObj.put("duration",lbl_notApplicable);
								detailsArray.add(detailsObj);

								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_BLOCK_WAIT_BEFORE_APPCACHE);
								detailsObj.put("duration",waitStartToFetch);
								detailsArray.add(detailsObj);
							}

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_RELATIVE_APPCACHE_DURATION);
							detailsObj.put("duration",appCache);
							detailsArray.add(detailsObj);

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_DNS_DURATION);
							detailsObj.put("duration",dnsTime);
							detailsArray.add(detailsObj);

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_BLOCK_WAIT_BEFORE_TCP);
							detailsObj.put("duration",waitBeforeConnect);
							detailsArray.add(detailsObj);
							
							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_TCP_CONNECT_DURATION);
							detailsObj.put("duration",connectTime);
							detailsArray.add(detailsObj);
							
							if(sslTime < 0){
								tmpObj.put("SSL", "-");

								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_SSL_CONNECT_DURATION);
								detailsObj.put("duration", lbl_notApplicable);
								detailsArray.add(detailsObj);
							}
							else{
								tmpObj.put("SSL", sslTime);

								detailsObj = new JSONObject();
								detailsObj.put("details",lbl_SSL_CONNECT_DURATION);
								detailsObj.put("duration",sslTime);
								detailsArray.add(detailsObj);
							}
							
							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_BLOCK_WAIT_BEFORE_REQUEST);
							detailsObj.put("duration",waitBeforeRequest);
							detailsArray.add(detailsObj); 
							
							detailsObj = new JSONObject();
							String resourceBTMLink = lbl_SERVER_PROCESSING_DURATION;
							if(m == 0 && !btmUrl.equals("") && pageTypeName != null && !(pageTypeName.equalsIgnoreCase("AJAX") || pageTypeName.equalsIgnoreCase("AJAXPAGE")) ){
								resourceBTMLink = "<a href='"+btmUrl+"'>"+lbl_SERVER_PROCESSING_DURATION+"&nbsp;&nbsp;<img src='/final/images/clear.png' class='iconDiagnosis' style='position:absolute;margin-left:2px;margin-top: 1px;'></a>";
							}
							detailsObj.put("details",resourceBTMLink);
							detailsObj.put("duration",serverTime);
							detailsArray.add(detailsObj);

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_CONTENT_DOWNLOAD_DURATION);
							detailsObj.put("duration",contentDownloadTime);
							detailsArray.add(detailsObj);

							tmpObj.put("redirection_time", redirectionTime);
							tmpObj.put("app_cache_time", appCache);
							tmpObj.put("dns_time", dnsTime);
							tmpObj.put("connect_time", connectTime);							

							tmpObj.put("serverTime_txt", serverTime);
							tmpObj.put("content_time", contentDownloadTime);
							tmpObj.put("actual_work_time", actualWorkTime);
							
							tmpObj.put(waitBeforeConnectTime, waitBeforeConnect);	
							tmpObj.put(waitBeforeRequestTime, waitBeforeRequest);

						}
						else
						{
							tmpObj.put(waitBeforeRedirectTime, lbl_notAvailable);
							tmpObj.put(waitAfterRedirectTime, lbl_notAvailable);
							tmpObj.put(waitStartFetchTime, lbl_notAvailable);
							tmpObj.put(waitBeforeConnectTime, lbl_notAvailable);
							tmpObj.put(waitBeforeRequestTime, lbl_notAvailable);
							tmpObj.put("total_block_wait_time", lbl_notAvailable);
							
							tmpObj.put("redirection_time", lbl_notAvailable);
							tmpObj.put("app_cache_time", lbl_notAvailable);
							tmpObj.put("dns_time", lbl_notAvailable);
							tmpObj.put("connect_time", lbl_notAvailable);
							tmpObj.put("ssl", lbl_notAvailable);
							tmpObj.put("serverTime_txt", lbl_notAvailable);
							tmpObj.put("content_time", lbl_notAvailable);
							tmpObj.put("actual_work_time", lbl_notAvailable);

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_BLOCK_WAIT_BEFORE_REDIRECT);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_REDIRECT_DURATION);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);
							
							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_BLOCK_WAIT_AFTER_REDIRECT);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_BLOCK_WAIT_BEFORE_APPCACHE);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);
							
							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_RELATIVE_APPCACHE_DURATION);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);
							
							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_DNS_DURATION);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);
							
							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_BLOCK_WAIT_BEFORE_TCP);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_TCP_CONNECT_DURATION);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);
							
							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_SSL_CONNECT_DURATION);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);
							
							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_BLOCK_WAIT_BEFORE_REQUEST);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_SERVER_PROCESSING_DURATION);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);

							detailsObj = new JSONObject();
							detailsObj.put("details",lbl_CONTENT_DOWNLOAD_DURATION);
							detailsObj.put("duration", lbl_notAvailable);
							detailsArray.add(detailsObj);
						}
						
						if(encodedBodySize < 0){
							tmpObj.put("encoded_body_size", "-");
						}
						else{
							tmpObj.put("encoded_body_size", getFileSize(encodedBodySize, "kb"));
						}

						if(decodedBodySize < 0){
							tmpObj.put("decoded_body_size", "-");
						}
						else{
							tmpObj.put("decoded_body_size", getFileSize(decodedBodySize, "kb"));
						}
						if(workerStart < 0){
							tmpObj.put("worker_start", "-");
						}
						else{
							tmpObj.put("worker_start", workerStart);
						}
						if(redirectCount < 0){
							tmpObj.put("redirect_count", "-");
						}
						else{
							tmpObj.put("redirect_count", redirectCount);
						}
					}
					catch(Exception ee)
					{
						ee.printStackTrace();
					}
					tmpObj.put("detailsArray", detailsArray);
					gridData.add(tmpObj);
				}
			}
			rootJson.put("gridData", gridData);
			resourceSizeObj.put("totalEncodedBodySize", getFileSize(totalEncodedBodySize, null));
			resourceSizeObj.put("totalDecodedBodySize", getFileSize(totalDecodedBodySize, null));
			resourceSizeObj.put("totalTransferSize", getFileSize(totalTransferSize, null));
			rootJson.put("resourceSize", resourceSizeObj);			
		}
		double totalTime = Double.parseDouble((String)rumDataTable.get(pageLoadTime));
		double browserTime = Double.parseDouble((String)rumDataTable.get(pageRenderTime));
		double backendTime = Double.parseDouble((String)rumDataTable.get(responseAvailableTime));
		double contentDownloadTime = Double.parseDouble((String)rumDataTable.get(documentReadyTime));
		double networkTime = Double.parseDouble((String)rumDataTable.get(serverConnectionTime));
		double dnsTime = Double.parseDouble((String)rumDataTable.get(dnsLookupTime));
		double tcpTime = Double.parseDouble((String)rumDataTable.get(tcpConnectTime));
		double _sslHandshakeTime = Double.parseDouble((String)rumDataTable.get(sslHandshakeTime));		
		// double networkTime = dnsTime+tcpTime+_sslHandshakeTime;
		// double redirectOrAppCache = networkTime - (dnsTime+tcpTime);
		double docDwnldTime = Double.parseDouble((String)rumDataTable.get(documentDownloadTime));
		double docprsngTime = Double.parseDouble((String)rumDataTable.get(documentProcessingTime));
		double slowUrlThrsld = Double.parseDouble((String)rumDataTable.get(slowUrlThreshold));
		double ajaxBackendTime = Double.parseDouble((String)rumDataTable.get(firstByteTime));
		double _browserWaitTime = Double.parseDouble((String)rumDataTable.get(browserWaitTime));
		double _redirectionTime = Double.parseDouble((String)rumDataTable.get(redirectionTime_txt));
		double _appCacheTime = Double.parseDouble((String)rumDataTable.get(appCacheTime));

		backendJson.put(btmTopologyUrl,btmUrl);

		String navSupport = (String)rumDataTable.get("IS_NAV_SUPPORT");
		boolean isNavSupport = true;
		if(navSupport !=null && navSupport.trim().length()>0 && navSupport.equalsIgnoreCase("NOT_SUPPORTED")){
			isNavSupport = false;
			rootJson.put("navSupport", "false");
		}
		else
			rootJson.put("navSupport", "true");
		double browserPercentage = 0.0d;
		double networkPercentage = 0.0d;
		double backendPercentage = 0.0d;
		double contentDownloadPercentage = 0.0d;
		String errorMsgValue = (String)rumDataTable.get(errorMessage);
		String pageTypeReq = (String)rumDataTable.get(pagetype);

		if (pageTypeReq != null && pageTypeReq.equalsIgnoreCase("Ajax")) { 
			 backendPercentage = Double.parseDouble(percentFormat.format((ajaxBackendTime/totalTime)*100));
			 contentDownloadPercentage = Double.parseDouble(percentFormat.format((docDwnldTime/totalTime)*100));
			 browserPercentage = Double.parseDouble(percentFormat.format((docprsngTime/totalTime)*100));
		} else {
			 double browserTime_page = browserTime+_browserWaitTime+_redirectionTime+_appCacheTime;
			 browserPercentage = Double.parseDouble(percentFormat.format((browserTime_page/totalTime)*100));
			 networkPercentage = Double.parseDouble(percentFormat.format((networkTime/totalTime)*100));
			 if(isNavSupport)
				 backendPercentage = Double.parseDouble(percentFormat.format((backendTime/totalTime)*100));
			 else
				 backendPercentage = Double.parseDouble(percentFormat.format((ajaxBackendTime/totalTime)*100));
			 contentDownloadPercentage = Double.parseDouble(percentFormat.format((contentDownloadTime/totalTime)*100));
		}

		String userName = rumDataTable.get(name).toString();
		if(userName == null || userName.equals("-") || userName.equals("-5")){
			userName = "";
		}
		userJson.put(name,userName);
		userJson.put(pageLoadTime,Math.round(totalTime));
		userJson.put(documentContentLoaded, Math.round(totalTime-browserTime));
		userJson.put(city,rumDataTable.get(city));
		userJson.put(region,rumDataTable.get(region));
		userJson.put(country,rumDataTable.get(country));
		userJson.put(countryCode,rumDataTable.get(countryCode));
		userJson.put(os,rumDataTable.get(os));
		userJson.put(ip,rumDataTable.get(ip));
		
		String gatewayIp_res = (String)rumDataTable.get(gatewayIp);
		if(gatewayIp_res != null && gatewayIp_res.startsWith("-5"))
			gatewayIp_res = "-";
		userJson.put(gatewayIp,gatewayIp_res);
		userJson.put(device,rumDataTable.get(device));
		userJson.put(rumUserExpKey,rumDataTable.get(rumUserExp));
		if(errorMsgValue != null && errorMsgValue != "-" && errorMsgValue.length() > 1)
		{
			//userJson.put(errorMessage,rumDataTable.get(errorMessage));
			int errorCount = 0;
			String finalErrorMsg = "";
			StringTokenizer st = new StringTokenizer(errorMsgValue,"]");
			while (st.hasMoreElements()) {
				String errorMsg = ((String) st.nextElement())+"]";
				if (errorMsg.startsWith(",")) {
					errorMsg = errorMsg.substring(1);
				}
				finalErrorMsg = finalErrorMsg+"<div>"+errorMsg+"</div>";
				errorCount = errorCount + 1;
			}
			userJson.put(errorMessage,finalErrorMsg);
			userJson.put(errorMsgCount,errorCount);
		}
		if(isNavSupport)
			networkJson.put(serverConnectionTime,Math.round(networkTime));
		else
			networkJson.put(serverConnectionTime,"-");

		if(isNavSupport){
			networkJson.put(lbl_DnsLookupTime,Math.round(dnsTime));
			networkJson.put(lbl_TcpConnectTime,Math.round(tcpTime));
		
			//networkJson.put(lbl_RedirectOrAppCacheKey,Math.round(redirectOrAppCache));
			if(_sslHandshakeTime == -5)
				networkJson.put(lbl_sslHandshakeTime,"-");
			else
				networkJson.put(lbl_sslHandshakeTime,Math.round(_sslHandshakeTime));
		}

		if (pageTypeReq != null && pageTypeReq.equalsIgnoreCase("Ajax")) {
			backendJson.put(responseAvailableTime,Math.round(ajaxBackendTime));
			contentDownloadJson.put(documentReadyTime, Math.round(docDwnldTime));
			browserJson.put(pageRenderTime,Math.round(browserTime));
		} else {

			if(isNavSupport)
				backendJson.put(responseAvailableTime,Math.round(backendTime));				
			else
				backendJson.put(responseAvailableTime,Math.round(ajaxBackendTime));
			backendJson.put(responseAvailableTime,Math.round(backendTime));
			contentDownloadJson.put(documentReadyTime, Math.round(contentDownloadTime));
			browserJson.put(pageRenderTime,Math.round(browserTime));
		}
		if(isNavSupport){
			contentDownloadJson.put(lbl_DocumentDownloadTime,Math.round(docDwnldTime));
			if (pageTypeReq != null && !pageTypeReq.equalsIgnoreCase("AjaxPage")) {
				contentDownloadJson.put(lbl_DocumentProcessingTime,Math.round(docprsngTime));
			}
		}
		if(isNavSupport)
		{
			browserJson.put(browserName,rumDataTable.get(browserName));
			browserJson.put(browserVersionKey,rumDataTable.get(browserVersion));
			browserJson.put(pagetype,rumDataTable.get(pagetype));
			browserJson.put(referrer,rumDataTable.get(referrer));
			if(_browserWaitTime == -5)
				browserJson.put(browserWaitTime,"-");
			else
				browserJson.put(browserWaitTime,Math.round(_browserWaitTime));
			if(_redirectionTime == -5)
				browserJson.put(redirectionTime_txt,"-");
			else
				browserJson.put(redirectionTime_txt,Math.round(_redirectionTime));
			if(_appCacheTime == -5)
				browserJson.put(appCacheTime,"-");
			else
				browserJson.put(appCacheTime,Math.round(_appCacheTime));
		}

		String urlParamsValue = (String)rumDataTable.get(urlParams);
		if(urlParamsValue == null || (urlParamsValue != null && urlParamsValue.equals("-5"))){
			urlParamsValue="";
		}
		headerJson.put(url,rumDataTable.get(url));
		headerJson.put(urlParams,urlParamsValue);

		String r_date = (String)rumDataTable.get(requestDate);
		String tzName = (String)rumDataTable.get(requestTimeZone);
		try
		{
			String stDate = r_date.substring(0,r_date.indexOf(" ")).trim();
			String stTime = r_date.substring(r_date.indexOf(" ")).trim();
			String userDateFormat= user.getUserDateFormat();
			if(DateUtil.isDate(stDate,"yyyy-MM-dd"))
			{
				stDate = DateUtil.changeDateFormat(stDate,"yyyy-MM-dd",userDateFormat);
			}
			if(DateUtil.isDate(stDate,"MM/dd/yyyy"))
			{
				stDate = DateUtil.changeDateFormat(stDate,"MM/dd/yyyy",userDateFormat);
			}
			EgTimeZoneConverter converter=new EgTimeZoneConverter(stDate+" "+stTime,user);
			r_date = (String)converter.getDate(false)+" "+converter.getHour()+":"+converter.getMinute()+":"+converter.getSecond();
			
			java.util.Date loginUserDate = (java.util.Date)converter.getDate(true);
			TimeZone tz = (TimeZone)converter.getTimeZone();
			tzName = tz.getDisplayName(tz.inDaylightTime(loginUserDate), TimeZone.SHORT);
		}
		catch(Exception eee)
		{
			r_date = (String) rumDataTable.get(requestDate);
			tzName= (String)rumDataTable.get(requestTimeZone);
		}

		headerJson.put(requestDate,r_date);
		headerJson.put(requestTimeZone,tzName);

		otherJson.put(slowUrlThreshold,Math.round(slowUrlThrsld));
		
		networkObj.put(valueKey,networkPercentage);
		networkObj.put(legendKey,networkPercentageKey);
		
		backendObj.put(valueKey,backendPercentage);
		backendObj.put(legendKey,backendPercentageKey);
		
		contentDwlObj.put(valueKey,contentDownloadPercentage);
		contentDwlObj.put(legendKey,contentDownloadPercentageKey);

		browserObj.put(valueKey,browserPercentage);
		browserObj.put(legendKey,browserPercentageKey);
		
		if(monitor_Skin.equals("Dark"))
		{
			networkObj.put(colorKey,networkColor_Dark);
			backendObj.put(colorKey,backendColor_Dark);
			contentDwlObj.put(colorKey,contentDwnlColor_Dark);
			browserObj.put(colorKey,browserColor_Dark);
		}
		else
		{
			networkObj.put(colorKey,networkColor_Light);
			backendObj.put(colorKey,backendColor_Light);
			contentDwlObj.put(colorKey,contentDwnlColor_Light);
			browserObj.put(colorKey,browserColor_Light);
		}
		if (isNavSupport && !pageTypeReq.equalsIgnoreCase("Ajax")){
			pieCharArray.add(networkObj);
		}
		pieCharArray.add(backendObj);
		pieCharArray.add(contentDwlObj);
		pieCharArray.add(browserObj);


		// Mapping Name Json Code Starts Here
		mappingNameObj.put(name,lbl_Name);
		mappingNameObj.put(guid,lbl_Guid);
		mappingNameObj.put(country,lbl_Country);
		mappingNameObj.put(region,lbl_Region);
		mappingNameObj.put(countryCode,lbl_CountryCode);
		mappingNameObj.put(rumUserExp,lbl_RumUserExp);
		mappingNameObj.put(rumUserExpKey,lbl_RumUserExpKey);
		mappingNameObj.put(requestDate,lbl_RequestDate);
		mappingNameObj.put(url,lbl_Url);
		mappingNameObj.put(pagetype,lbl_Pagetype);
		mappingNameObj.put(referrer,lbl_Referrer);
		mappingNameObj.put(ip,lbl_Ip);
		mappingNameObj.put(gatewayIp,lbl_GatewayIp);
		mappingNameObj.put(device,lbl_Device);
		mappingNameObj.put(os,lbl_Os);
		mappingNameObj.put(errorMessage,lbl_ErrorMessage);
		mappingNameObj.put(requestTimeZone,lbl_RequestTimeZone);
		mappingNameObj.put(sessionid,lbl_Sessionid);
		mappingNameObj.put(slowUrlThreshold,lbl_SlowUrlThreshold);
		mappingNameObj.put(browserName,lbl_BrowserName);
		mappingNameObj.put(browserNameKey,lbl_BrowserNameKey);
		mappingNameObj.put(browserVersion,lbl_BrowserVersion);
		mappingNameObj.put(browserVersionKey,lbl_BrowserVersionKey);
		mappingNameObj.put(pageLoadTime,lbl_PageLoadTime);
		mappingNameObj.put(frontEndTime,lbl_FrontEndTime);
		mappingNameObj.put(pageRenderTime,lbl_PageRenderTime);
		mappingNameObj.put(documentReadyTime,lbl_DocumentReadyTime);
		mappingNameObj.put(documentDownloadTime,lbl_DocumentDownloadTime);
		mappingNameObj.put(documentProcessingTime,lbl_DocumentProcessingTime);
		mappingNameObj.put(serverConnectionTime,lbl_ServerConnectionTime);
		mappingNameObj.put(dnsLookupTime,lbl_DnsLookupTime);
		mappingNameObj.put(tcpConnectTime,lbl_TcpConnectTime);
		mappingNameObj.put(responseAvailableTime,lbl_ResponseAvailableTime);
		mappingNameObj.put(redirectOrAppCacheKey,lbl_RedirectOrAppCacheKey);
		mappingNameObj.put(browserPercentageKey,lbl_BrowserPercentageKey);
		
		mappingNameObj.put(waitBeforeRedirectTime,lbl_WAIT_BEFORE_REDIRECT_TIME);
		mappingNameObj.put(waitAfterRedirectTime,lbl_WAIT_AFTER_REDIRECT_TIME);
		mappingNameObj.put(waitStartFetchTime,lbl_WAIT_START_FETCH_TIME);
		mappingNameObj.put(blockWaitBeforeRedirect,lbl_BLOCK_WAIT_BEFORE_REDIRECT);
		mappingNameObj.put(redirectDuration,lbl_REDIRECT_DURATION);
		mappingNameObj.put(blockWaitAfterRedirect,lbl_BLOCK_WAIT_AFTER_REDIRECT);
		mappingNameObj.put(blockWaitBeforeAppCache,lbl_BLOCK_WAIT_BEFORE_APPCACHE);
		mappingNameObj.put(relativeAppCacheDuration,lbl_RELATIVE_APPCACHE_DURATION);
		mappingNameObj.put(dnsDuration,lbl_DNS_DURATION);
		mappingNameObj.put(blockWaitBeforeTCP,lbl_BLOCK_WAIT_BEFORE_TCP);
		mappingNameObj.put(tcpConnectDuration,lbl_TCP_CONNECT_DURATION);
		mappingNameObj.put(sslConnectDuration,lbl_SSL_CONNECT_DURATION);
		mappingNameObj.put(blockWaitBeforeRequest,lbl_BLOCK_WAIT_BEFORE_REQUEST);
		mappingNameObj.put(serverProcessingDuration,lbl_SERVER_PROCESSING_DURATION);
		mappingNameObj.put(contentDownloadDuration,lbl_CONTENT_DOWNLOAD_DURATION);
		mappingNameObj.put(waitBeforeConnectTime,lbl_WAIT_BEFORE_CONNECT_TIME);
		mappingNameObj.put(waitBeforeRequestTime,lbl_WAIT_BEFORE_REQUEST_TIME);
		
		mappingNameObj.put(browserWaitTime,lbl_browserWaitTime);
		mappingNameObj.put(appCacheTime,lbl_appCacheTime);
		mappingNameObj.put(sslHandshakeTime,lbl_sslHandshakeTime);
		mappingNameObj.put(redirectionTime_txt,lbl_REDIRECTION_TIME);
		mappingNameObj.put(networkConnectionTime,lbl_NETWORK_CONNECTION_TIME);
		mappingNameObj.put(browserTime_key,lbl_BROWSER_TIME);
		mappingNameObj.put(resourceFetchRenderingTime,lbl_RESOURCE_FETCH_RENDERING_TIME);
		mappingNameObj.put(request,lbl_REQUEST);
		mappingNameObj.put(response,lbl_RESPONSE);
		mappingNameObj.put(serverTime_txt,lbl_SERVER_TIME);
		mappingNameObj.put(URLParameters,lbl_URL_PARAMETERS);
		mappingNameObj.put(requestfor,lbl_REQUEST_FOR);
		mappingNameObj.put(at,lbl_AT);
		mappingNameObj.put(rumTransactionDetails,lbl_RUM_TRANSACTION_DETAILS);
		mappingNameObj.put(resourceDetails,lbl_RESOURCE_DETAILS);
		mappingNameObj.put(back,lbl_BACK);
		mappingNameObj.put(ajaxCallBackTime,lbl_AJAX_CALL_BACK_TIME);
		mappingNameObj.put(ajaxCall,lbl_AJAX_CALL);
		mappingNameObj.put(contentDownloadTime_txt,lbl_CONTENT_DOWNLOAD_TIME);
		mappingNameObj.put(serverTime_txt,lbl_SERVER_TIME);
		mappingNameObj.put(breakupPageLoadTime,lbl_BREAKUP_OF_PAGE_LOAD_TIME);
		mappingNameObj.put(htmlDownloadTime, lbl_HTML_DOWNLOAD_TIME);
		mappingNameObj.put(noDataFound,lbl_NO_DATA_FOUND);
		
		mappingNameObj.put(requests,lbl_REQUESTS);
		mappingNameObj.put(transferred,lbl_TRANSFERRED);
		mappingNameObj.put(documentContentLoaded,lbl_documentContentLoaded);
		mappingNameObj.put(clientInformation,lbl_CLIENT_INFORMATION);
		mappingNameObj.put(resources,lbl_RESOURCES);
		mappingNameObj.put(domain,lbl_DOMAIN);
		mappingNameObj.put(type,lbl_TYPE);
		mappingNameObj.put(relativeStartTime,lbl_RELATIVE_START_TIME);
		mappingNameObj.put(duration,lbl_DURATION);
		mappingNameObj.put(splitOfDuration,lbl_SPLIT_OF_DURATION);
		mappingNameObj.put(actualWork,lbl_ACTUAL_WORK);
		mappingNameObj.put(block_wait,lbl_BLOCK_WAIT);
		mappingNameObj.put(transferSize,lbl_TRANSFER_SIZE);
		mappingNameObj.put(resourceName,lbl_RESOURCE_NAME);
		mappingNameObj.put(actualWorkTime_txt,lbl_ACTUAL_WORK_TIME);
		mappingNameObj.put(blockTime,lbl_BLOCk_WAIT_TIME);
		mappingNameObj.put(percTimeSplit,lbl_PERCENTAGE_TIME_SPLIT);
		mappingNameObj.put(browserNavgationFlow,lbl_BROWSER_NAVIGATION_FLOW);
		
		mappingNameObj.put(browserNotSupport,lbl_BROWSER_NOT_SUPPORT);
		mappingNameObj.put(browserNotSupportResourceAPI,lbl_BROWSER_NOT_SUPPORT_RESOURCE_API);
		mappingNameObj.put(forAJAXRequest,lbl_FOR_AJAX_REQUEST);
		
		mappingNameObj.put(noDataFound,lbl_NO_DATA_FOUND);
		mappingNameObj.put(location,lbl_LOCATION);
		mappingNameObj.put(ajaxCallBackTime_ms,lbl_AJAX_CALLBACK_TIME_MS);
		mappingNameObj.put(browserTime_ms,lbl_BROWSER_TIME_MS);
		mappingNameObj.put(call,lbl_CALL);
		mappingNameObj.put(resourceDownload,lbl_RESOURCE_DOWNLOAD);
		mappingNameObj.put(networkConnecionBreakUp,lbl_NETWORK_CONNECTION_BREAK_UP);
		mappingNameObj.put(millisecond,lbl_MILLISEC);
		mappingNameObj.put(error,lbl_ERROR);
		mappingNameObj.put(on,lbl_ON);

		if(isNavSupport)
			mappingNameObj.put(networkPercentageKey,lbl_NetworkPercentageKey);
		mappingNameObj.put(backendPercentageKey,lbl_BackendPercentageKey);
		mappingNameObj.put(contentDownloadPercentageKey,lbl_ContentDownloadPercentageKey);
		// Mapping Name Json Code Ends Here

		allJson.put("skin",monitor_Skin);
		allJson.put("user_Info",userJson);
		allJson.put("network_Info",networkJson);
		allJson.put("backend_Info",backendJson);
		allJson.put("contentDownload_Info",contentDownloadJson);
		allJson.put("browser_Info",browserJson);
		allJson.put("header_Info",headerJson);
		allJson.put("other_Info",otherJson);
		allJson.put("pieChart_Info",pieCharArray);
		allJson.put("mappingName_Info",mappingNameObj);
		rootJson.put("rumTopology",allJson);

		//System.out.println("RootJson Result is : "+rootJson);
		return rootJson;
	}

%>
<!DOCTYPE html>
<html id="rumBTM">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width"/>
		<title>RUM Topology</title>
	
<script>
	var isMyDashboard='<%=comesFrom%>';
	if(isMyDashboard!=null && isMyDashboard=="MyDashboard")
	{
		var strSkin='<%=monitor_Skin%>';
		if(strSkin!=null && strSkin=='Dark')
		{
			document.write('<link rel="stylesheet" href="/final/resources/css/ext-eg.css"  media="all"/>');
			document.write('<link rel="stylesheet" href="/final/styles/eGDarkTheme.css" media="all" />');
			document.write('<link rel="stylesheet" href="/final/styles/eGDarkThemeIcons.css"  media="all" />');
		}
		else
		{
			document.write('<link rel="stylesheet" href="/final/resources/css/ext-eg.css"  media="all"/>');
			document.write('<link rel="stylesheet" href="/final/styles/eGLightTheme.css" media="all" />');
			document.write('<link rel="stylesheet" href="/final/styles/eGLightThemeIcons.css"  media="all" />');
		}
	}
	else
	{	
		document.write('<egui:skin ui="monitor"/>');
	}
</script>		

		<!--<script type="text/javascript" src="/final/extjs/ext-all.js"></script>-->
		<!--<script type="text/javascript" src="/final/jquery/jquery.js"></script>-->
		<!--Old Jquery refering in the name of highchart_export.js -->
		<script type="text/javascript" src="/final/jquery/highchart_export.js"></script>
		<!-- script src="/final/scripts/d3.min.js" script -->
		<script src="/final/Highcharts/js/highstock.js"></script>
		<script src="/final/Highcharts/js/modules/exporting.js"></script>

	<style>
		.x-tip.yellowTip.stdWidth
		{
		    word-break: break-all;
			max-width:500px !important;
		}
	</style>

	</head>	
	<body>
<%
	
	String rumGuid = request.getParameter("rumGuid");
	String testName = request.getParameter("testName");
	String hide_bck_button="false";
	String isReporterRequest = request.getParameter("isReporterRequest");
	if(isReporterRequest!=null && isReporterRequest.trim().length()>0 && isReporterRequest.equalsIgnoreCase("yes"))
		hide_bck_button="true";	
	//String rumGuid = "01605428-b2e2-4e3b-9e53-4e9193660ec0-1458105847642";
	JSONObject jsonResult = new JSONObject();
	String rumQuery  = "SELECT  distinct GUID , APPLICATION_NAME , COUNTRY , REGION , CITY , COUNTRY_CODE , RUM_USER_EXP , REQUEST_DATE , URL , PAGETYPE , REFERRER , IP, DEVICE ,OS , ERROR_MESSAGE, REQUEST_TIME_ZONE, SESSIONID, SLOW_URL_THRESHOLD, BROWSER, BROWSER_VERSION , PAGE_LOAD_TIME, FRONT_END_TIME , PAGE_RENDER_TIME , DOCUMENT_READY_TIME, DOCUMENT_DOWNLOAD_TIME ,DOCUMENT_PROCESSING_TIME ,SERVER_CONNECTION_TIME , DNSLOOKUPTIME, TCPCONNECTTIME, RESPONSE_AVAILABLE_TIME, FIRST_BYTE_TIME, IS_NAV_SUPPORT, IS_RSRC_SUPPORT, GATEWAY_IP,SSL_HANDSHAKE_TIME,APP_CACHE_TIME,REDIRECTION_TIME,BROWSER_WAIT_TIME,BTM_GUID,BTM_NODE_ORDER,USER_NAME, URL_PARAMS FROM RUM_DETAILS WHERE guid ='"+rumGuid+"'";
	UserRegistry registry = UserRegistry.getInstance();
	User user = registry.getUser(session.getId());

	Hashtable rumDataTable = RUMHelper.getRumMeasures(rumQuery);
	if(rumDataTable.get("IS_NAV_SUPPORT") != null){
		String isNav=rumDataTable.get("IS_NAV_SUPPORT").toString();
		isNav=RUMHelper.getIsNavigationAPISupported(isNav);
		rumDataTable.put("IS_NAV_SUPPORT",isNav);
	}	
	Hashtable rumResourceDataTable = null;
	boolean needToHideResourceTap = true;
	if(rumDataTable.get("IS_RSRC_SUPPORT") != null){
		String isRsrc=rumDataTable.get("IS_RSRC_SUPPORT").toString();
		isRsrc=RUMHelper.getIsResourceAPISupported(isRsrc);
		rumDataTable.put("IS_RSRC_SUPPORT",isRsrc);
		
		if(isRsrc!=null && isRsrc.trim().length()>0 && isRsrc.equalsIgnoreCase("SUPPORTED")){
			needToHideResourceTap = false;
			String rumResourceQuery = "SELECT GUID ,RESOURCE_DETAILS FROM RUM_RESOURCE_DETAILS WHERE guid ='"+rumGuid+"'";
			rumResourceDataTable = RUMHelper.getRumResourceDetails(rumResourceQuery);
		}
	}
	jsonResult = rumJsonBuild(monitor_Skin, rumDataTable, mappingInfo, rumResourceDataTable,user);
	//System.out.println("------------------- "+jsonResult);
	%>
	
	<script>
		var rumGuid = '<%=rumGuid%>';
		var data = <%=jsonResult%>;
		var hide_bck_button = <%=hide_bck_button%>;
		var hideResourceTab=<%=needToHideResourceTap%>;
		var pageType = '<%=pageTypeName%>';

	</script>
	<!--<script src="/final/monitor/eg_scripts/RUMtopologygraph.js"></script>-->
	<egui:loadApp baseDir="/final/monitor/eg_scripts" appName="RumRequestFlow/app"/>
	
	</body>
<html>