<%@ taglib prefix = "egui" uri = "../../../WEB-INF/eg-taglib.tld"%>
<%@ page language="java" contentType="application/json; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import ="com.eg.EgAlarmTable"%>
<%@ page import = "com.eg.EgMappingInfo"%>
<%@ page import = "com.eg.EgTablesInfo"%>
<%@ page import = "egurkha.TransactionBean"%>
<%@ page import = "net.sf.json.JSONObject"%>
<%@ page import="com.egurkha.EgUserRole"%>
<%@ include file="../../../admin/EgAdminTracker.jsp" %>
<%
	try
	{
		//UserRegistry registry = UserRegistry.getInstance();
		User user = registry.getUser(session.getId());
		com.egurkha.ini.IniUI uiObj = (com.egurkha.ini.IniUI)com.egurkha.ini.IniUI.getInstance();
		String thisLanguage = uiObj.getDefaultLanguage();

		String CustomAlertMessages = "No";//for customize the problem description 
		boolean isCustomAlertMessages = false;//for customize the problem description 
		boolean isInfoExistsInCustomAlarmDescription = false;
		TransactionBean configMsgBean = null;
		configMsgBean = new TransactionBean();
		configMsgBean.createFile("eg_services.ini");
		CustomAlertMessages = configMsgBean.getStrValue("MISC_ARGS", "EnableCustomAlertMessages");
		if(CustomAlertMessages != null && CustomAlertMessages.equalsIgnoreCase("Yes")) {
			isCustomAlertMessages = true;
		}
		boolean hasVMs = false;
		if (user!=null)
		{
			String userLang = user.getLanguage();
			if (userLang!=null && !userLang.equalsIgnoreCase("NULL"))
			{
				thisLanguage=userLang;
			}
			EgUserRole userRole = user.getUserRole();
			List a_userVMs = new LinkedList();
			boolean hasAllComponentAccess = userRole.hasAllComponentAccess();
			if (!hasAllComponentAccess)
			{
				a_userVMs = user.getOnlyVMs();
				if (a_userVMs != null && a_userVMs.size() > 0)
				{
					hasVMs = true;
				}
			}
		}
		EgMappingInfo mappingInfo = new EgMappingInfo(thisLanguage);
		String entry=request.getParameter("entry");
		EgAlarmTable alm_table=new EgAlarmTable();
		EgTablesInfo tablesInfo_sort = new EgTablesInfo(EgConstants.MANAGER);

		String qAlmHeader ="<div style='float:left;margin:0px 4px 0px 2px;' class='indexQuickLinksHeader'>"+mappingInfo.getTextDescription("admin.profile.Quick Alerts")+"</div><div style='float:right;cursor:pointer;cursor:hand' class='iconQuickLinksClose' id='closeQuickAlarm' title='Close'></div><div style='float:right;margin:4px 20px 0px 2px;cursor:pointer;cursor:hand' class='iconMaximizeGray'  id='maxAlarmView'></div>";

		JSONObject json = new JSONObject();
		json.put("qAlmHeader",qAlmHeader);
		json.put("currentAlmLink","/final/monitor/EgAlarms.jsp?iframe=true&width=990&height=400");
	
		String egConfigDir = EgInstallInfo.getInstallDir() + "/manager/config/";
		String dashboardConfig = "eg_dashboardConfig.ini";
		IniFile dashboardConfigIni = new IniFile(egConfigDir + dashboardConfig);
		
		String hide_Test[] = dashboardConfigIni.getVariables("HIDE_MEASURES_FROM_UI_ALARMS");
		ArrayList hideAllTest = new ArrayList();
		Hashtable hideMeasures = new Hashtable();
		
		if(hide_Test!=null && hide_Test.length>0)
		{
			for(int m=0; m<hide_Test.length; m++)
			{	
				String test_val = hide_Test[m];
				String hide_TestVal=(String)dashboardConfigIni.getValue("HIDE_MEASURES_FROM_UI_ALARMS",test_val);
				
				if(hide_TestVal!= null && hide_TestVal.equalsIgnoreCase("All"))
				{
					hideAllTest.add(test_val);
				}
				else
				{
					if(hide_TestVal!= null && hide_TestVal.trim().length() >0 && !hide_TestVal.equalsIgnoreCase("All"))
					{
						ArrayList hide_Measure = com.egurkha.util.StringUtils.egTokenizer(hide_TestVal, ",", false,true,false);
						hideMeasures.put(test_val,hide_Measure);
					}
					
				}
			}
		}	

		Vector v_user_comp = new Vector();
		v_user_comp.addAll(user.getServers(false));
		HashSet user_comp_notype = new HashSet();		
		List sitesList = (List)user.getSites();
		for (int x = 0; x < v_user_comp.size(); x++)
		{
			String s_tmp = (String) v_user_comp.elementAt(x);
			s_tmp = s_tmp.substring(s_tmp.indexOf(":") + 1);
			String actualComp = s_tmp;
			if(actualComp!=null && !actualComp.endsWith(":NULL"))
			{
				if (s_tmp.indexOf(":") > -1)
					s_tmp = s_tmp.substring(0, s_tmp.indexOf(":"));
				s_tmp = s_tmp + ":NULL";
				user_comp_notype.add(s_tmp);
				user_comp_notype.add(actualComp);
			}
			else
			{
				user_comp_notype.add(s_tmp);
			}
		}
		Map alarmTableValue=(HashMap)alm_table.getAlaramTableQuickView();
		//Map priorityCount=(HashMap)alm_table.getPriorityCount();
		if(alarmTableValue!=null && alarmTableValue.size() > 0)
		{
			StringBuffer critcialAlertsSb = new StringBuffer(512);
			ArrayList criticalDesc=(ArrayList)alarmTableValue.get("Critical");		
			HashSet criticalSet = new HashSet();
			int criticalAlarmCount=0;
			if(criticalDesc!=null)
			{
				StringTokenizer st=null;
				for(int i=0;i<criticalDesc.size();i=i+4)
				{
					String CompName=(String)criticalDesc.get(i);					
					String actualCompName = CompName;
					if(CompName.indexOf(":NULL")>0)
					{
						CompName=CompName.substring(0,CompName.indexOf(":"));
					}
					if( !user_comp_notype.contains(actualCompName))
					{
						continue;
					}
					String compType =  (String)criticalDesc.get(i+1);
					String layer = (String) criticalDesc.get(i+2);
					String desc=(String)criticalDesc.get(i+3);
					if(desc.indexOf("|")>0)
					{						
						st=new StringTokenizer(desc,"|");
						int j=0;
						Vector criticalLink=new Vector();
						Vector infoVector=new Vector();
						while(st.hasMoreTokens())
						{
							String descAlone=(String)st.nextToken();
							StringTokenizer stt=new StringTokenizer(descAlone,",");
							String qryStr="qctr=2^fromalarm=1^showDashBoardLink=true^fromalarmWindow=true^gotoLayerModel=true^tstate=HIGH";
							qryStr+="^host="+actualCompName;
							qryStr+="^layer="+layer;
							String site = (String)stt.nextToken();
							if((site!=null && !site.equalsIgnoreCase("NULL")) && (sitesList!=null && !sitesList.contains(site)))
							{
								continue;
							}
							String msmt_host = (String)stt.nextToken();
							String info=(String)stt.nextToken();
							String testMeasure=(String)stt.nextToken();
							String test = testMeasure.substring(0,testMeasure.indexOf(":"));
							String meas= testMeasure.substring(testMeasure.indexOf(":")+1);
						
							if(hideAllTest != null && hideAllTest.size() > 0 && hideAllTest.contains(test))
							{
								continue;
							}
							else if(hideMeasures != null && hideMeasures.containsKey(test))
							{
								ArrayList measureList = (ArrayList)hideMeasures.get(test);

								if(measureList != null && measureList.size() > 0 && measureList.contains(meas))
									continue;
							}

							test=test+"-"+(com.egurkha.util.StringUtils.replace(info, "+", ""));
							test=com.egurkha.util.StringUtils.replace(test, "\\", "\\\\");
							test=com.egurkha.util.StringUtils.replace(test, "#", "|hash|");
							String testVal = com.egurkha.util.StringUtils.encodeSecurityChar(test);
							qryStr+="^site="+site+"^test="+testVal+"^msmt_host="+msmt_host+"^comptype="+compType;
							qryStr=com.egurkha.util.StringUtils.replace(qryStr, "=", "|eq|");
							if(j==0)
							{
								criticalLink.add(testMeasure);
								criticalLink.add(com.egurkha.util.StringUtils.replace(info, "+", ""));
								criticalLink.add(qryStr);
								//infoVector.add(com.egurkha.util.StringUtils.replace(info, "+", ""));
							}
							else
							{
								criticalLink.add(testMeasure);
								info=com.egurkha.util.StringUtils.replace(info, "+", "").trim();
								criticalLink.add(info);
								criticalLink.add(qryStr);
							}
							j++;
						}
						if(criticalLink.size()>0 )
						{
							Hashtable alertParams = new Hashtable();
							for(int k=0;k<criticalLink.size();k=k+3)
							{		
								
								String testMeasure = (String)criticalLink.get(k);
								String displayInfo = (String)criticalLink.get(k+1);
								String testName = testMeasure.substring(0, testMeasure.indexOf(":"));
								String measureName = testMeasure.substring(testMeasure.indexOf(":") + 1);
								String measAlert = "";
								isInfoExistsInCustomAlarmDescription = false;
								
								//custom problem alert description
								int len=0;
								if(isCustomAlertMessages)
								{
									measAlert = mappingInfo.getCustomMeasureAlert(testMeasure);
									len = measAlert.trim().length();
									if(measAlert != null && len > 0 && measAlert.indexOf("$info") > -1)
									{
										isInfoExistsInCustomAlarmDescription = true;
										measAlert = replaceMsg (measAlert, Server.getServerNameWithoutPort(actualCompName, false), mappingInfo.getComponentTypeDescription(compType), "-", mappingInfo.getLabelDescription("HIGH"), mappingInfo.getLayerDescription(layer), mappingInfo.getTestDescription(testName), displayInfo, mappingInfo.getMeasureDescription(testName, measureName), "");
									}
								} 
								if(measAlert == null || len == 0){
									alertParams = new Hashtable();
									alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(compType));
									alertParams.put("$componentName",Server.getServerNameWithoutPort(actualCompName, false));
									if(displayInfo!=null && displayInfo.trim().length()>1){
										if(displayInfo.startsWith("+"))
											alertParams.put("$info",displayInfo.substring(1));
										else
											alertParams.put("$info",displayInfo);
									}
									alertParams.put("hasVMs",hasVMs);
									//alertParams.put("appendTag",new Boolean(false));
									 measAlert = (String) mappingInfo.getMeasureAlert(testMeasure,alertParams);
									 if(measAlert != null && measAlert.indexOf("~!~") != -1){
										isInfoExistsInCustomAlarmDescription = Boolean.parseBoolean(measAlert.substring(measAlert.indexOf("~!~")+3));
										measAlert = measAlert.substring(0,measAlert.indexOf("~!~"));
									}
								}

								if(criticalSet!=null && !criticalSet.contains(compType+":"+CompName+"|critical|"+measAlert+"{"+displayInfo+"}"))
								{
									criticalAlarmCount++;
									if(!isInfoExistsInCustomAlarmDescription) { 
										measAlert = measAlert + "{" + displayInfo + "}";
									}
									//quickmenuAlarmHoverStyleAlter ; quickmenuAlarmHoverStyle
									critcialAlertsSb.append("<tr><td class='x-grid-cell x-grid-cell-first  quickmenuAlarmTableBottomBorder'><a href='javascript:void(0)' onclick='javascript:wayToLayerModel(\""+criticalLink.get(k+2)+"\");'>");
									critcialAlertsSb.append("<div style='float:left;width:150px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip='"+CompName+"' >"+CompName+"</div>");
									critcialAlertsSb.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip=\""+measAlert+"\">" + measAlert);
									critcialAlertsSb.append("</div></a></td></tr>");

									criticalSet.add(compType+":"+CompName+"|critical|" + measAlert);
								}
							}
						}
					}
					else
					{						
						st=new StringTokenizer(desc,",");
						String qryStr="qctr=2^fromalarm=1^showDashBoardLink=true^fromalarmWindow=true^gotoLayerModel=true^tstate=HIGH";
						
						qryStr+="^host="+actualCompName;
						qryStr+="^layer="+layer;
						String site = (String)st.nextToken();
						if((site!=null && !site.equalsIgnoreCase("NULL")) && (sitesList!=null && !sitesList.contains(site)))
						{
							continue;
						}
						String msmt_host = (String)st.nextToken();
						String info=(String)st.nextToken();
						String tmpInfo = com.egurkha.util.StringUtils.replace(info, "+", "").trim();
						String testMeasure =(String)st.nextToken();
						String test = testMeasure.substring(0,testMeasure.indexOf(":"));
						String testName = test;
						String measureName = testMeasure.substring(testMeasure.indexOf(":") + 1);
						
						if(hideAllTest != null && hideAllTest.size() > 0 && hideAllTest.contains(testName))
						{
							continue;
						}
						else if(hideMeasures != null && hideMeasures.containsKey(testName))
						{
							ArrayList measureList = (ArrayList)hideMeasures.get(testName);

							if(measureList != null && measureList.size() > 0 && measureList.contains(measureName))
								continue;
						}
					
						String measAlert = "";
						isInfoExistsInCustomAlarmDescription = false;
						test=test+"-";
						if(!info.equals("") && info!=null )
						{
							info=com.egurkha.util.StringUtils.replace(info,"=","|equ|");
							test+=info;
						}
						String testVal = com.egurkha.util.StringUtils.encodeSecurityChar(test);
						qryStr+="^site="+site+"^test="+testVal+"^msmt_host="+msmt_host+"^comptype="+compType;

						qryStr=com.egurkha.util.StringUtils.replace(qryStr, "=", "|eq|");
						//custom problem alert description
						int len = 0;
						if(isCustomAlertMessages)
						{
							measAlert = mappingInfo.getCustomMeasureAlert(testMeasure);
							len = measAlert.trim().length();
							if(measAlert != null && len > 0 && measAlert.indexOf("$info")>-1)
							{
								isInfoExistsInCustomAlarmDescription = true;
								measAlert = replaceMsg (measAlert, Server.getServerNameWithoutPort(actualCompName, false), mappingInfo.getComponentTypeDescription(compType), "-",mappingInfo.getLabelDescription("HIGH"), mappingInfo.getLayerDescription(layer), mappingInfo.getTestDescription(testName), tmpInfo, mappingInfo.getMeasureDescription(testName, measureName), "");
							}				
						} 
						if(measAlert == null || len == 0){
							Hashtable alertParams = new Hashtable();
							alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(compType));
							alertParams.put("$componentName",Server.getServerNameWithoutPort(actualCompName, false));
							if(tmpInfo!=null && tmpInfo.trim().length()>1){
								if(tmpInfo.startsWith("+"))
									alertParams.put("$info",tmpInfo.substring(1));
								else
									alertParams.put("$info",tmpInfo);
							}
							alertParams.put("hasVMs",hasVMs);
							//alertParams.put("appendTag",new Boolean(false));
							measAlert = (String)mappingInfo.getMeasureAlert(testMeasure,alertParams);
							if(measAlert != null && measAlert.indexOf("~!~") != -1){
								isInfoExistsInCustomAlarmDescription = Boolean.parseBoolean(measAlert.substring(measAlert.indexOf("~!~")+3));
								measAlert = measAlert.substring(0,measAlert.indexOf("~!~"));
							}
						}

						if(!info.equals("+"))
						{
							StringTokenizer criticaldesc = new StringTokenizer(info,"+");
							while ( criticaldesc.hasMoreTokens())
							{
								info = criticaldesc.nextToken();
								if(criticalSet!=null && !criticalSet.contains(compType+":"+CompName+"|critical|"+measAlert+"{"+info+"}"))
								{	
									criticalAlarmCount++;
									if(!isInfoExistsInCustomAlarmDescription) { 
										measAlert = measAlert + "{" + info + "}";
									}
									
									critcialAlertsSb.append("<tr><td class='x-grid-cell x-grid-cell-first  quickmenuAlarmTableBottomBorder'><a href='javascript:void(0)' id='layermodelLink' onclick='javascript:wayToLayerModel(\""+qryStr+"\");'>");
									critcialAlertsSb.append("<div style='float:left;width:150px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip='"+CompName+"'>"+CompName+"</div>");
									critcialAlertsSb.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip=\""+measAlert+"\" >"+measAlert+ "</div></a>");

									criticalSet.add(compType+":"+CompName+"|critical|"+measAlert);
								}
							}
						}
						else
						{
							if(criticalSet!=null && !criticalSet.contains(compType+":"+CompName+"|critical|"+measAlert))
							{
								criticalAlarmCount++;
								critcialAlertsSb.append("<tr><td class='x-grid-cell x-grid-cell-first quickmenuAlarmTableBottomBorder'><a href='javascript:void(0)' id='layermodelLink'  onclick='javascript:wayToLayerModel(\""+qryStr+"\");'>");
								critcialAlertsSb.append("<div style='float:left;width:150px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip='"+CompName+"' >"+CompName+"</div>");
								critcialAlertsSb.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip=\""+measAlert+"\" >"+measAlert+ "</div></a>");

								criticalSet.add(compType+":"+CompName+"|critical|"+measAlert);
							}
						}
						critcialAlertsSb.append("</td></tr>");
					}
				}						
				critcialAlertsSb.append("</table>");			
				StringBuffer criticalAlarmsHeader=new StringBuffer();
				if ( criticalAlarmCount > 0 )
				{					
					criticalAlarmsHeader.append("<table width='100%' class='quicklinkAlarmTable'><tr class='x-grid-row'><th width='100%' class='quicklinkAlarmTableHeader'>");
					criticalAlarmsHeader.append("<div style='float:left;line-height:1.5em'><div class='state_HIGH' style='float:left;margin:4px 2px 2px 4px'></div>");
					criticalAlarmsHeader.append("<div style='float:left;padding:4px 10px 4px 4px;'>"+mappingInfo.getTextDescription("admin.profile.Critical")+"</div>");
					criticalAlarmsHeader.append("</div><div style='float:right;margin:4px 10px 2px 2px;line-height:1.5em' class='iconQuickLinksCount'>"+criticalAlarmCount+"</div></th></tr>");
					criticalAlarmsHeader.append("<tr><td width='100%' class='quicklinkAlarmTableTh'><div style='float:left;width:150px;padding:4px 10px 4px 10px;' >"+mappingInfo.getTextDescription("admin.profile.Component Name")+"</div>");
					criticalAlarmsHeader.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;' >"+mappingInfo.getTextDescription("admin.profile.Description")+"</div>");
					criticalAlarmsHeader.append("</td></tr>");
				}		
				json.put("CriticalAlerts",criticalAlarmsHeader.toString()+critcialAlertsSb.toString());
			}			

			//code for major alerts
			StringBuffer majorqLinkAlerts = new StringBuffer(500);
			ArrayList majorDesc=(ArrayList)alarmTableValue.get("Major");
			int majorAlarmCount=0;
			HashSet majorSet = new HashSet();
			if(majorDesc!=null)
			{					
				StringTokenizer st=null;
				for(int i=0;i<majorDesc.size();i=i+4)
				{	
					String CompName=(String)majorDesc.get(i);
				
					String actualCompName = CompName;
					if(CompName.indexOf(":NULL")>0)
					{
						CompName=CompName.substring(0,CompName.indexOf(":"));
					}
					if( !user_comp_notype.contains(actualCompName))
					{
						continue;
					}
					String compType =  (String)majorDesc.get(i+1);
					String layer = (String) majorDesc.get(i+2);
					String desc=(String)majorDesc.get(i+3);
					if(desc.indexOf("|")>0)
					{
						st=new StringTokenizer(desc,"|");
						int j=0;
						Vector majorLink = new Vector();
						Vector infoVector = new Vector();
						while(st.hasMoreTokens())
						{
							String descAlone=(String)st.nextToken();
							StringTokenizer stt=new StringTokenizer(descAlone,",");
							String qryStr="qctr=2^fromalarm=1^showDashBoardLink=true^fromalarmWindow=true^gotoLayerModel=true^tstate=INTERMEDIATE";								
							qryStr+="^host="+actualCompName;
							qryStr+="^layer="+layer;
							String site = (String)stt.nextToken();
							if((site!=null && !site.equalsIgnoreCase("NULL")) && (sitesList!=null && !sitesList.contains(site)))
							{
								continue;
							}
							String msmt_host = (String)stt.nextToken();
							String info=(String)stt.nextToken();
							String testMeasure=(String)stt.nextToken();
							String test = testMeasure.substring(0,testMeasure.indexOf(":"));
							String meas= testMeasure.substring(testMeasure.indexOf(":")+1);

							if(hideAllTest != null && hideAllTest.size() > 0 && hideAllTest.contains(test))
							{
								continue;
							}
							else if(hideMeasures != null && hideMeasures.containsKey(test))
							{
								ArrayList measureList = (ArrayList)hideMeasures.get(test);

								if(measureList != null && measureList.size() > 0 && measureList.contains(meas))
									continue;
							}
							info=com.egurkha.util.StringUtils.replace(info,"=","|equ|");
							info=com.egurkha.util.StringUtils.replace(info, "+", "");
							test=test+"-"+info;
							test=com.egurkha.util.StringUtils.replace(test, "\\", "\\\\");
							test=com.egurkha.util.StringUtils.replace(test, "#", "|hash|");
							String testVal = com.egurkha.util.StringUtils.encodeSecurityChar(test);
							qryStr+="^site="+site+"^test="+testVal+"^msmt_host="+msmt_host+"^comptype="+compType;
							qryStr=com.egurkha.util.StringUtils.replace(qryStr, "=", "|eq|");
							if(j==0)
							{
								majorLink.add(testMeasure);
								majorLink.add(com.egurkha.util.StringUtils.replace(info, "+", ""));
								majorLink.add(qryStr);
								//infoVector.add(com.egurkha.util.StringUtils.replace(info, "+", ""));
							}
							else
							{
								majorLink.add(testMeasure);
								info=com.egurkha.util.StringUtils.replace(info, "+", "").trim();
								majorLink.add(info);
								majorLink.add(qryStr);	
							}
							j++;
						}
						if(majorLink.size()>0)
						{
							Hashtable alertParams = new Hashtable();
							for(int k=0;k<majorLink.size();k=k+3)
							{

								String testMeasure = (String)majorLink.get(k);
								String displayInfo = (String)majorLink.get(k+1);
								String testName = testMeasure.substring(0, testMeasure.indexOf(":"));
								String measureName = testMeasure.substring(testMeasure.indexOf(":") + 1);
								String measAlert = "";
								isInfoExistsInCustomAlarmDescription = false;
								
								//custom problem alert description
								int len = 0;
								if(isCustomAlertMessages)
								{
									measAlert = mappingInfo.getCustomMeasureAlert(testMeasure);
									len = measAlert.trim().length();
									if(measAlert != null && len > 0 && measAlert.indexOf("$info")>-1)
									{
										isInfoExistsInCustomAlarmDescription = true;
										measAlert = replaceMsg (measAlert, Server.getServerNameWithoutPort(actualCompName, false), mappingInfo.getComponentTypeDescription(compType), "-",mappingInfo.getLabelDescription("INTERMEDIATE"), mappingInfo.getLayerDescription(layer), mappingInfo.getTestDescription(testName), displayInfo, mappingInfo.getMeasureDescription(testName, measureName), "");
									}
								} 
								if(measAlert == null || len == 0 ){
									alertParams = new Hashtable();
									alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(compType));
									alertParams.put("$componentName",Server.getServerNameWithoutPort(actualCompName, false));
									if(displayInfo!=null && displayInfo.trim().length()>1){
										if(displayInfo.startsWith("+"))
											alertParams.put("$info",displayInfo.substring(1));
										else
											alertParams.put("$info",displayInfo);
									}
									//alertParams.put("appendTag",new Boolean(false));
									alertParams.put("hasVMs",hasVMs);
									 measAlert = (String) mappingInfo.getMeasureAlert(testMeasure,alertParams);
									 if(measAlert != null && measAlert.indexOf("~!~") != -1){
										isInfoExistsInCustomAlarmDescription = Boolean.parseBoolean(measAlert.substring(measAlert.indexOf("~!~")+3));
										measAlert = measAlert.substring(0,measAlert.indexOf("~!~"));
									}
								}
								if(majorSet!=null && !majorSet.contains(compType+":"+CompName+"|Major|"+measAlert+"{"+displayInfo+"}"))
								{
									majorAlarmCount++;
									if(!isInfoExistsInCustomAlarmDescription) { 
										measAlert = measAlert + "{" + displayInfo + "}";
									}
									
									majorqLinkAlerts.append("<tr><td class='x-grid-cell x-grid-cell-first  quickmenuAlarmTableBottomBorder'><a href='javascript:void(0)' onclick='javascript:wayToLayerModel(\""+majorLink.get(k+2)+"\");'>");
									majorqLinkAlerts.append("<div style='float:left;width:150px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip='"+CompName+"'>"+CompName+"</div>");
									majorqLinkAlerts.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip=\""+measAlert+"\" >"+measAlert+"</div>");
									majorqLinkAlerts.append("</a></td>");

									majorSet.add(compType+":"+CompName+"|Major|"+measAlert);
								}
							}
							majorqLinkAlerts.append("</tr> ");
						}
					}
					else
					{						
						st=new StringTokenizer(desc,",");
						String qryStr="qctr=2^fromalarm=1^showDashBoardLink=true^fromalarmWindow=true^gotoLayerModel=true^tstate=INTERMEDIATE";
						
						qryStr+="^host="+actualCompName;
						qryStr+="^layer="+layer;
						String site = (String)st.nextToken();
						if((site!=null && !site.equalsIgnoreCase("NULL")) && (sitesList!=null && !sitesList.contains(site)))
						{
							continue;
						}
						String msmt_host = (String)st.nextToken();
						String info = (String)st.nextToken();
						String tmpInfo = com.egurkha.util.StringUtils.replace(info, "+", "").trim();
						String testMeasure=(String)st.nextToken();
						String test = testMeasure.substring(0,testMeasure.indexOf(":"));
						String testName = test;
						String meas = testMeasure.substring(testMeasure.indexOf(":") + 1);
						
						if(hideAllTest != null && hideAllTest.size() > 0 && hideAllTest.contains(testName))
						{
							continue;
						}
						else if(hideMeasures != null && hideMeasures.containsKey(testName))
						{
							ArrayList measureList = (ArrayList)hideMeasures.get(testName);

							if(measureList != null && measureList.size() > 0 && measureList.contains(meas))
								continue;
						}
						
						String measAlert = "";
						isInfoExistsInCustomAlarmDescription = false;
						info=com.egurkha.util.StringUtils.replace(info,"=","|equ|");
						info=com.egurkha.util.StringUtils.replace(info, "+", "");
						test=test+"-"+info;
						test=com.egurkha.util.StringUtils.replace(test, "\\", "\\\\");
						test=com.egurkha.util.StringUtils.replace(test, "#", "|hash|");
						String testVal = com.egurkha.util.StringUtils.encodeSecurityChar(test);
						qryStr+="^site="+site+"^test="+testVal+"^msmt_host="+msmt_host+"^comptype="+compType;
						qryStr=com.egurkha.util.StringUtils.replace(qryStr, "=", "|eq|");
						//custom problem alert description
						int len = 0;
						if(isCustomAlertMessages)
						{
							measAlert = mappingInfo.getCustomMeasureAlert(testMeasure);
							len = measAlert.trim().length();
							if(measAlert != null && len > 0 && measAlert.indexOf("$info") > -1)
							{
								isInfoExistsInCustomAlarmDescription = true;
								measAlert = replaceMsg (measAlert, Server.getServerNameWithoutPort(actualCompName, false), mappingInfo.getComponentTypeDescription(compType), "-",mappingInfo.getLabelDescription("INTERMEDIATE"), mappingInfo.getLayerDescription(layer), mappingInfo.getTestDescription(testName), tmpInfo, mappingInfo.getMeasureDescription(testName, meas), "");
							}
						} 
						if(measAlert == null || len == 0 ){
							Hashtable alertParams = new Hashtable();
							alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(compType));
							alertParams.put("$componentName",Server.getServerNameWithoutPort(actualCompName, false));
							if(tmpInfo!=null && tmpInfo.trim().length()>1){
								if(tmpInfo.startsWith("+"))
									alertParams.put("$info",tmpInfo.substring(1));
								else
									alertParams.put("$info",tmpInfo);
							}
							//alertParams.put("appendTag",new Boolean(false));
							alertParams.put("hasVMs",hasVMs);
							 measAlert = (String) mappingInfo.getMeasureAlert(testMeasure,alertParams);
							 if(measAlert != null && measAlert.indexOf("~!~") != -1){
								isInfoExistsInCustomAlarmDescription = Boolean.parseBoolean(measAlert.substring(measAlert.indexOf("~!~")+3));
								measAlert = measAlert.substring(0,measAlert.indexOf("~!~"));
							}
						}
						
						if(!info.equals("+"))
						{
							StringTokenizer mgrdesc = new StringTokenizer(info,"+");
							while ( mgrdesc.hasMoreTokens())
							{
								info = mgrdesc.nextToken();
								if(majorSet!=null && !majorSet.contains(compType+":"+CompName+"|Major|"+measAlert+"{"+info+"}"))
								{	
									majorAlarmCount++;
									if(!isInfoExistsInCustomAlarmDescription) { 
										measAlert = measAlert + "{" + info + "}";
									}
									
									majorqLinkAlerts.append("<tr><td class='x-grid-cell x-grid-cell-first  quickmenuAlarmTableBottomBorder'><a href='javascript:void(0)' id='layermodelLink' onclick='javascript:wayToLayerModel(\""+qryStr+"\");'>");
									majorqLinkAlerts.append("<div style='float:left;width:150px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip='"+CompName+"'>"+CompName+"</div>");
									majorqLinkAlerts.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip=\""+measAlert+"\">"+measAlert);

									majorSet.add(compType+":"+CompName+"|Major|"+measAlert);
								}
							}
						}
						else
						{
							if(majorSet!=null && !majorSet.contains(compType+":"+CompName+"|Major|"+measAlert))
							{
								majorAlarmCount++;
								majorqLinkAlerts.append("<tr><td class='x-grid-cell x-grid-cell-first  quickmenuAlarmTableBottomBorder'><a href='javascript:void(0)' id='layermodelLink' onclick='javascript:wayToLayerModel(\""+qryStr+"\");'>");
								majorqLinkAlerts.append("<div style='float:left;width:150px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip='"+CompName+"'>"+CompName+"</div>");
								majorqLinkAlerts.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip=\""+measAlert+"\" >"+measAlert);

								majorSet.add(compType+":"+CompName+"|Major|"+measAlert);
							}
						}
						majorqLinkAlerts.append("</div></a></td></tr>");
					}
				}
				majorqLinkAlerts.append("</table>");
				StringBuffer majorAlarmsHeader=new StringBuffer();
				if(majorAlarmCount > 0)
				{
					majorAlarmsHeader.append("<table width='100%' class='x-table quicklinkAlarmTable'><tr><th width='100%' class='quicklinkAlarmTableHeader'>");
					majorAlarmsHeader.append("<div style='float:left;line-height:1.5em'><div class='state_INTERMEDIATE' style='float:left;margin: 4px 2px 2px 4px'></div>");
					majorAlarmsHeader.append("<div style='float:left;padding:4px 10px 4px 4px;'>"+mappingInfo.getTextDescription("admin.profile.Major")+"</div>");
					majorAlarmsHeader.append("</div><div style='float:right;margin:4px 10px 2px 2px;line-height:1.5em' class='iconQuickLinksCount'>"+majorAlarmCount+"</div></th></tr>");
					majorAlarmsHeader.append("<tr><td width='100%' class='quicklinkAlarmTableTh'><div style='float:left;width:150px;padding:4px 10px 4px 10px;' >"+mappingInfo.getTextDescription("admin.profile.Component Name")+"</div>");
					majorAlarmsHeader.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;' >"+mappingInfo.getTextDescription("admin.profile.Description")+"</div>");
					majorAlarmsHeader.append("</td></tr>");
				}
				json.put("MajorAlerts",majorAlarmsHeader.toString()+majorqLinkAlerts.toString());
			}
			//code for minor
			StringBuffer minorqLinkAlerts = new StringBuffer(500);
			int minorAlarmCount=0;
			HashSet minorSet = new HashSet();
			ArrayList minorDesc=(ArrayList)alarmTableValue.get("Minor");
			if(minorDesc!=null)
			{
				StringTokenizer st=null;
				for(int i=0;i<minorDesc.size();i=i+4)
				{	
					String CompName=(String)minorDesc.get(i);
					String actualCompName = CompName;
					if(CompName.indexOf(":NULL")>0)
					{
						CompName=CompName.substring(0,CompName.indexOf(":"));
					}
					
					if( !user_comp_notype.contains(actualCompName))
					{
						continue;
					}
					String compType =  (String)minorDesc.get(i+1);
					String layer = (String) minorDesc.get(i+2);
					String desc=(String)minorDesc.get(i+3);
					if(desc.indexOf("|")>0)
					{
						st=new StringTokenizer(desc,"|");
						int j=0;
						Vector minorLink = new Vector();
						Vector infoVector = new Vector();
						while(st.hasMoreTokens())
						{
							String descAlone=(String)st.nextToken();
							StringTokenizer stt=new StringTokenizer(descAlone,",");
							String qryStr="qctr=2^fromalarm=1^showDashBoardLink=true^fromalarmWindow=true^gotoLayerModel=true^tstate=LOW";
							qryStr+="^host="+actualCompName;
							qryStr+="^layer="+layer;
							String site = (String)stt.nextToken();
							if((site!=null && !site.equalsIgnoreCase("NULL")) && (sitesList!=null && !sitesList.contains(site)))
							{
								continue;
							}
							String msmt_host = (String)stt.nextToken();
							String info=(String)stt.nextToken();
							String testMeasure=(String)stt.nextToken();
							String test = testMeasure.substring(0,testMeasure.indexOf(":"));
							String meas= testMeasure.substring(testMeasure.indexOf(":")+1);

							if(hideAllTest != null && hideAllTest.size() > 0 && hideAllTest.contains(test))
							{
								continue;
							}
							else if(hideMeasures != null && hideMeasures.containsKey(test))
							{
								ArrayList measureList = (ArrayList)hideMeasures.get(test);

								if(measureList != null && measureList.size() > 0 && measureList.contains(meas))
									continue;
							}
							info=com.egurkha.util.StringUtils.replace(info,"=","|equ|");
							info=com.egurkha.util.StringUtils.replace(info, "+", "");
							test=test+"-"+info;
							test=com.egurkha.util.StringUtils.replace(test, "\\", "\\\\");
							test=com.egurkha.util.StringUtils.replace(test, "#", "|hash|");
							String testVal = com.egurkha.util.StringUtils.encodeSecurityChar(test);
							qryStr+="^site="+site+"^test="+testVal+"^msmt_host="+msmt_host+"^comptype="+compType;
							qryStr=com.egurkha.util.StringUtils.replace(qryStr, "=", "|eq|");
							if(j==0)
							{
								minorLink.add(testMeasure);
								minorLink.add(com.egurkha.util.StringUtils.replace(info, "+", ""));
								minorLink.add(qryStr);
							}
							else
							{
								minorLink.add(testMeasure);
								info=com.egurkha.util.StringUtils.replace(info, "+", "").trim();
								minorLink.add(info);
								minorLink.add(qryStr);
							}							
							j++;
						}
						if(minorLink.size()>0)
						{
							Hashtable alertParams = new Hashtable();
							for(int k=0;k<minorLink.size();k=k+3)
							{
								String testMeasure = (String)minorLink.get(k);
								String displayInfo = (String) minorLink.get(k+1);
					
								String testName = testMeasure.substring(0, testMeasure.indexOf(":"));
								String measureName = testMeasure.substring(testMeasure.indexOf(":") + 1);
								String measAlert = "";
								isInfoExistsInCustomAlarmDescription = false;
								
								//custom problem alert description
								int len = 0;
								if(isCustomAlertMessages)
								{
									measAlert = mappingInfo.getCustomMeasureAlert(testMeasure);
									len = measAlert.trim().length();
									if(measAlert != null && len > 0 && measAlert.indexOf("$info") > -1)
									{
										isInfoExistsInCustomAlarmDescription = true;
										measAlert = replaceMsg (measAlert, Server.getServerNameWithoutPort(actualCompName, false), mappingInfo.getComponentTypeDescription(compType), "-", mappingInfo.getLabelDescription("LOW"), mappingInfo.getLayerDescription(layer), mappingInfo.getTestDescription(testName), displayInfo, mappingInfo.getMeasureDescription(testName, measureName), "");
									}
								}
								if(measAlert == null || len == 0){
									alertParams = new Hashtable();
									alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(compType));
									alertParams.put("$componentName",Server.getServerNameWithoutPort(actualCompName, false));
									if(displayInfo!=null && displayInfo.trim().length()>1){
										if(displayInfo.startsWith("+"))
											alertParams.put("$info",displayInfo.substring(1));
										else
											alertParams.put("$info",displayInfo);
									}
									//alertParams.put("appendTag",new Boolean(false));
									alertParams.put("hasVMs",hasVMs);
									 measAlert = (String) mappingInfo.getMeasureAlert(testMeasure,alertParams);
									 if(measAlert != null && measAlert.indexOf("~!~") != -1){
										isInfoExistsInCustomAlarmDescription = Boolean.parseBoolean(measAlert.substring(measAlert.indexOf("~!~")+3));
										measAlert = measAlert.substring(0,measAlert.indexOf("~!~"));
									}
								}

								if(minorSet!=null && !minorSet.contains(compType+":"+CompName+"|minor|"+measAlert+"{"+displayInfo+"}"))
								{
									minorAlarmCount++;
									if(!isInfoExistsInCustomAlarmDescription) { 
										measAlert = measAlert + "{" + displayInfo + "}";
									}
									minorqLinkAlerts.append("<tr><td class='x-grid-cell x-grid-cell-first  quickmenuAlarmTableBottomBorder'><a href='javascript:void(0)' onclick='javascript:wayToLayerModel(\""+minorLink.get(k+2)+"\");'>");
									minorqLinkAlerts.append("<div style='float:left;width:150px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip='"+CompName+"'>"+CompName+"</div>");
									minorqLinkAlerts.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip=\""+measAlert+"\">"+measAlert);	
									minorqLinkAlerts.append("</div></a></td></tr>");

									minorSet.add(compType+":"+CompName+"|minor|"+measAlert);
								}
							}	
						}
					}
					else
					{						
						st=new StringTokenizer(desc,",");
						String qryStr="qctr=2^fromalarm=1^showDashBoardLink=true^fromalarmWindow=true^gotoLayerModel=true^tstate=LOW";
						
						qryStr+="^host="+actualCompName;
						qryStr+="^layer="+layer;
						String site = (String)st.nextToken();
						if((site!=null && !site.equalsIgnoreCase("NULL")) && (sitesList!=null && !sitesList.contains(site)))
						{
							continue;
						}
						String msmt_host = (String)st.nextToken();
						String info=(String)st.nextToken();
						String testMeasure=(String)st.nextToken();
						String test = testMeasure.substring(0,testMeasure.indexOf(":"));
						String meas = testMeasure.substring(testMeasure.indexOf(":") + 1);
						String testName = test;
						if(hideAllTest != null && hideAllTest.size() > 0 && hideAllTest.contains(testName))
						{
							continue;
						}
						else if(hideMeasures != null && hideMeasures.containsKey(testName))
						{
							ArrayList measureList = (ArrayList)hideMeasures.get(testName);

							if(measureList != null && measureList.size() > 0 && measureList.contains(meas))
								continue;
						}
						String tmpInfo = com.egurkha.util.StringUtils.replace(info, "+", "").trim();
						String measAlert = "";
						isInfoExistsInCustomAlarmDescription = false;
						test=test+"-";
						if(!info.equals("") && info!=null )
						{
							info=com.egurkha.util.StringUtils.replace(info,"=","|equ|");
							info=com.egurkha.util.StringUtils.replace(info, "+", "");
							test+=info;
						}
						String testVal = com.egurkha.util.StringUtils.encodeSecurityChar(test);
						qryStr+="^site="+site+"^test="+testVal+"^msmt_host="+msmt_host+"^comptype="+compType;
						qryStr=com.egurkha.util.StringUtils.replace(qryStr, "=", "|eq|");
						//custom problem alert description
						int len = 0;
						if(isCustomAlertMessages)
						{
							measAlert = mappingInfo.getCustomMeasureAlert(testMeasure);
							len = measAlert.trim().length();			
							if(measAlert != null && len > 0 && measAlert.indexOf("$info") > -1)
							{
								isInfoExistsInCustomAlarmDescription = true;
								measAlert = replaceMsg (measAlert, Server.getServerNameWithoutPort(actualCompName, false), mappingInfo.getComponentTypeDescription(compType), "-", mappingInfo.getLabelDescription("LOW"), mappingInfo.getLayerDescription(layer), mappingInfo.getTestDescription(testName), tmpInfo, mappingInfo.getMeasureDescription(testName, meas), "");
							}
						} 
						if(measAlert == null || len == 0){
							Hashtable alertParams = new Hashtable();
							alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(compType));
							alertParams.put("$componentName",Server.getServerNameWithoutPort(actualCompName, false));
							if(tmpInfo!=null && tmpInfo.trim().length()>1){
								if(tmpInfo.startsWith("+"))
									alertParams.put("$info",tmpInfo.substring(1));
								else
									alertParams.put("$info",tmpInfo);
							}
							//alertParams.put("appendTag",new Boolean(false));
							alertParams.put("hasVMs",hasVMs);
							 measAlert = (String)mappingInfo.getMeasureAlert(testMeasure,alertParams);
							 if(measAlert != null && measAlert.indexOf("~!~") != -1){
								isInfoExistsInCustomAlarmDescription = Boolean.parseBoolean(measAlert.substring(measAlert.indexOf("~!~")+3));
								measAlert = measAlert.substring(0,measAlert.indexOf("~!~"));
							}
						}

						if(!info.equals("+"))
						{
							StringTokenizer minordesc = new StringTokenizer(info,"+");
							while ( minordesc.hasMoreTokens())
							{
								info = minordesc.nextToken();
								if(minorSet!=null && !minorSet.contains(compType+":"+CompName+"|minor|"+measAlert+"{"+info+"}"))
								{
									minorAlarmCount++;
									if(!isInfoExistsInCustomAlarmDescription) { 
										measAlert = measAlert + "{" + info + "}";
									}
									minorqLinkAlerts.append("<tr class='x-grid-cell x-grid-cell-first'><td class='x-grid-cell x-grid-cell-first  quickmenuAlarmTableBottomBorder'><a href='javascript:void(0)' id='layermodelLink' onclick='javascript:wayToLayerModel(\""+qryStr+"\");'>");
									minorqLinkAlerts.append("<div style='float:left;width:150px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip='"+CompName+"'>"+CompName+"</div>");
									minorqLinkAlerts.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip=\""+measAlert+"\" >"+measAlert+"</div></a>");

									minorSet.add(compType+":"+CompName+"|minor|"+measAlert);
								}
							}
						}
						else
						{
							if(minorSet!=null && !minorSet.contains(compType+":"+CompName+"|minor|"+measAlert))
							{
								minorAlarmCount++;
								minorqLinkAlerts.append("<tr><td class='x-grid-cell x-grid-cell-first  quickmenuAlarmTableBottomBorder'><a href='javascript:void(0)' id='layermodelLink' onclick='javascript:wayToLayerModel(\""+qryStr+"\");'>");
								minorqLinkAlerts.append("<div style='float:left;width:150px;padding:4px 10px 4px 10px;line-height:1.5em' data-qclass='yellowTip' data-qtip='"+CompName+"'>"+CompName+"</div>");
								minorqLinkAlerts.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;line-height:1.5em;' data-qclass='yellowTip' data-qtip=\""+measAlert+"\" >"+measAlert+"</div></a>");

								minorSet.add(compType+":"+CompName+"|minor|"+measAlert);
							}
						}						
						minorqLinkAlerts.append("</td></tr>");
					}	
				}
				minorqLinkAlerts.append("</table>");
				StringBuffer minorAlarmsHeader=new StringBuffer();
				if(minorAlarmCount > 0)
				{
					minorAlarmsHeader.append("<table width='100%' class='x-table quicklinkAlarmTable'><tr><th width='100%' class='quicklinkAlarmTableHeader'>");
					minorAlarmsHeader.append("<div style='float:left;line-height:1.5em'><div class='state_LOW' style='float:left;margin:4px 2px 2px 4px'></div>");
					minorAlarmsHeader.append("<div style='float:left;padding:4px 10px 4px 4px;'>"+mappingInfo.getTextDescription("admin.profile.Minor")+"</div>");
					minorAlarmsHeader.append("</div><div style='float:right;margin:4px 10px 2px 2px;line-height:1.5em' class='iconQuickLinksCount'>"+minorAlarmCount+"</div></th></tr>");
					minorAlarmsHeader.append("<tr><td width='100%' class='quicklinkAlarmTableTh'><div style='float:left;width:150px;padding:4px 10px 4px 10px;' >"+mappingInfo.getTextDescription("admin.profile.Component Name")+"</div>");
					minorAlarmsHeader.append("<div style='float:left;width:236px;padding:4px 10px 4px 10px;' >"+mappingInfo.getTextDescription("admin.profile.Description")+"</div>");
					minorAlarmsHeader.append("</td></tr>");
				}
				json.put("MinorAlerts",minorAlarmsHeader.toString()+minorqLinkAlerts.toString());
			}
			//code for total updates
			if( criticalAlarmCount <= 0 && majorAlarmCount <= 0 && minorAlarmCount <= 0)
			{
				json.put("dataAvailable","false");
				StringBuffer alarmEmpty = new StringBuffer(550);
				alarmEmpty.append("<table width='400px' height='400px'><tr><td align='center' valign='middle'><div>");
				alarmEmpty.append("<div class='iconNoalarms' style='margin:0px auto'></div>"+mappingInfo.getTextDescription("monitor.current.No alarms found")+"</div></td></tr></table>");
				json.put("alarmEmpty",alarmEmpty.toString());
			}
			else
			{
				int totalCount = 0;
				totalCount = criticalAlarmCount+ majorAlarmCount + minorAlarmCount;
				StringBuffer totalUpdate = new StringBuffer(550);
				totalUpdate.append("<table width='400px' class='x-table border_alt' style='border-collapse:collapse;width:410px'><tr><th width='100%' class='quicklinkAlarmTableHeader'>");
				totalUpdate.append("<div style='float:left;line-height:1.5em'><div id='QuickAlrmRefresh' class='iconRefresh' style='float:left;margin:6px;cursor:pointer;cursor:hand;' title='Refresh'></div>");
				totalUpdate.append("<div style='float:left;padding:4px;'>Total Alerts</div></div>");
				totalUpdate.append("<div style='float:right;margin:4px 10px 2px 2px;line-height:1.5em' class='iconQuickLinksCount'>"+totalCount+"</div></th></tr></table>");
				
				json.put("totalUpdateValue",totalUpdate.toString());
				json.put("dataAvailable","true");
			}
		}
		else
		{
			json.put("dataAvailable","false");
			StringBuffer alarmEmpty = new StringBuffer(550);
			alarmEmpty.append("<table width='400px' height='400px'><tr><td align='center' valign='middle'><div>");
			alarmEmpty.append("<div class='iconNoalarms' style='margin:0px auto'></div>"+mappingInfo.getTextDescription("monitor.current.No alarms found")+"</div></td></tr></table>");
			json.put("alarmEmpty",alarmEmpty.toString());
		}
		session.setAttribute("globalSearchLastSessionval","");
		response.getWriter().write(json.toString());
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
%>
<%!

		/**
		* This method is used to get custom problem alert description. 
		* @param message -Problem alert description
		* @param Compname -Component name
		* @param CompType -Component type
		* @param Service -Service name
		* @param Priority -Priority critical|major|minor
		* @param Layer - Layer name
		* @param Test -Test name 
		* @param info -Descriptor details 
		* @param Measure -Measure name 
		* @param LastMeasurevalue - Last measure value
		* @return String This returns the custom problem alert description.
		*/
		
		private String replaceMsg (String message,String Compname,String CompType,String Service,String Priority,String Layer,String Test,String info,String Measure,String LastMeasurevalue)
		{
			message = replace(message,"$Compname",Compname);
			message = replace(message,"$CompType",CompType);
			message = replace(message,"$Service",Service);
			message = replace(message,"$Priority",Priority);
			message = replace(message,"$Layer",Layer);
			message = replace(message,"$Test",Test);
			String tempInfoStr="";
			if(info!=null && !info.trim().equals("+"))
			{
				tempInfoStr=info;
			}
			message = replace(message,"$info",tempInfoStr);
			message = replace(message,"$Measure",Measure);
			message = replace(message,"$LastMeasurevalue",LastMeasurevalue);
			return message.toString();
		}
		private String replace (String s,String s_search,String s_replace)
		{
			StringBuffer sb_tmp = new StringBuffer();
			while(s.indexOf(s_search) > -1)
			{
			   sb_tmp.append(s.substring(0,s.indexOf(s_search)) + s_replace);
				s = s.substring(s.indexOf(s_search) + s_search.length(),s.length());
			}
			if(s.length() > 0)
			sb_tmp.append(s);
			return sb_tmp.toString();
		}
%>