%@ page contentType="text/html; charset=utf-8" %>
<%@ include file="/oemNoscript.jspf" %>
<%@ taglib uri="http://xmlns.oracle.com/uix/ui" prefix="uix" %>
<%@ taglib uri="http://xmlns.oracle.com/oem/jsp/tag" prefix="oem" %>
<%@ page import='oracle.sysman.emSDK.page.seg.PageSegmentContext' %>
<%@ page import='java.text.MessageFormat' %>
<%@ page import='java.util.ResourceBundle' %>
<%@ page import='java.util.ArrayList' %>
<%@ page import='java.util.Calendar,java.util.TimeZone' %>
<%@ page import='java.util.Date,java.util.Enumeration' %>
<%@ page import='java.util.Locale' %>
<%@ page import='java.util.TimeZone' %>
<%@ page import='java.text.DateFormat' %>
<%@ page import='java.text.SimpleDateFormat' %>
<%@ page import='java.text.ParseException' %>
<%@ page import='oracle.sysman.emSDK.util.jdk.NLSUtil' %>
<%@ page import='oracle.sysman.eml.ip.render.elem.emr.services.util.SLUtil' %>
<%@ page import='oracle.sysman.eml.ip.render.elem.emr.services.util.SLDBHelper' %>
<%@ page import='oracle.sysman.eml.ip.render.elem.emr.services.constants.ServiceConstants' %>
<%@ page import='oracle.sysman.resources.eml.ip.emr.services.ServicesMsgID' %>
<%@ page import='oracle.sysman.resources.eml.ip.emr.services.ServicesMsg' %>
<%@ page import='oracle.sysman.emSDK.util.jdk.TimeZoneDisplay' %>
<%@ page import='java.util.regex.Matcher' %>
<%@ page import='java.util.regex.Pattern' %>
<%@ page import='oracle.sysman.emSDK.util.jdk.URLUtil' %>
<%@ page import=' oracle.sysman.emSDK.sec.auth.LoginUtil' %>
<%!
//method for getting values from request
public String getRequestParam(HttpServletRequest request,String paramName) {
String reqMethod = request.getMethod();
String paramValue = request.getParameter(paramName);
//if it is queried by URL, the expected params are selTimeValue,selTimeZone and rptTZ
//for other params, return null
if(reqMethod.equals("GET")){
if(paramName.equals("selTimeValue") || paramName.equals("selTimeZone")
|| paramName.equals(ServiceConstants.SELECTED_TIMEZONE)){
paramValue = URLUtil.decode(paramValue);
return paramValue;
}else{
return null;
}
}
//since user provided textbox values are not encoded
//they are not decoded here. so that, users can see whatever they entered
if(paramName.equals("date1")
|| paramName.equals("date2")
|| paramName.equals("prevTxtBox")){
return paramValue;
}else{
paramValue = URLUtil.decode(paramValue);
return paramValue;
}
}
%>
<%
/////////////////////////////
//Prevent unauthorized access
//////////////////////////////
String loginUser = LoginUtil.getUserName(request);
if(loginUser==null || loginUser.trim().length()==0){
response.sendError(response.SC_UNAUTHORIZED);
return;
}
//[ Find out the popup needs Timezone and some spacial cases
// like carrying the selected time range from parent page etc
boolean tpFlag=false,resetSelTimeValue=false;
String sDate = "";
String eDate = "";
if(getRequestParam(request,"tpFlag")!=null){
tpFlag = new Boolean(getRequestParam(request,"tpFlag")).booleanValue();
resetSelTimeValue = true;
}else{
Enumeration paramNames = request.getParameterNames();
String parm;
while(paramNames.hasMoreElements()) {
parm = (String)paramNames.nextElement();
if(parm.equals("selTimeValue")){
tpFlag = true;
sDate = getRequestParam(request,"selTimeValue");
if(sDate!=null && sDate.indexOf(":")>0 && sDate.substring(0,sDate.indexOf(":")).equals("3")){
sDate = sDate.substring(sDate.indexOf(":")+1,sDate.length());
if(sDate.indexOf(":")>-1){
eDate = sDate.substring(sDate.indexOf(":")+1,sDate.length());
sDate = sDate.substring(0,sDate.indexOf(":"));
}
}else{
sDate="";
}
}
}
paramNames=null;parm=null;
}
String selTimePeriod = "";
int selTzIndex = -1;
ArrayList tzValueList = new ArrayList();
ArrayList tzTextList = new ArrayList();
String selTimeZone = "",selTimeZoneID=null;
if(tpFlag){
if(getRequestParam(request,"selTimeValue") != null){
selTimePeriod = (String)getRequestParam(request,"selTimeValue");
if( selTimePeriod.indexOf(":") <1){
selTimePeriod = "0:0";
}
//check for selTimePeriod should not having any chars except (0-9,:,-)
//because the expected value for selTimePeriod is like
//"3:01-10-2004:02-11-2004" or "0:0" or "0:20:0"
Pattern p = Pattern.compile("[^0-9:-]");
Matcher m = p.matcher(selTimePeriod);
if(m.find()){ //if event param contains any special chars except 0-9,- and :
selTimePeriod = "0:0";
}
}
else if(resetSelTimeValue){ selTimePeriod=""; }
else{ selTimePeriod = "0:0"; }
//Getting timeZone list
TimeZoneDisplay[] arryTimeZoneDisplay=null;
String regionOfHost = TimeZone.getDefault().getDisplayName();
//Getting selected Time zone
if(getRequestParam(request,"selTimeZone") != null){
selTimeZone=(TimeZone.getTimeZone((String)getRequestParam(request,"selTimeZone"))).getDisplayName();
}
else{
selTimeZone = regionOfHost;
}
arryTimeZoneDisplay = NLSUtil.getTimeZonesForDisplay(request);
//String regionOfHost = TimeZone.getDefault().getID();
if(arryTimeZoneDisplay!=null){
String tzID = null;
for(int i=0;i
<% if(tpFlag){%> <%}else{%>
<%}%>
<%
ResourceBundle rb = NLSUtil.getBundle(ServicesMsg.class.getName(),
request);
Object nlsParams[] = new Object[1];
String timeZoneID = (String)getRequestParam(request,
ServiceConstants.SELECTED_TIMEZONE);
if(tpFlag){ timeZoneID = selTimeZoneID; }
if(timeZoneID == null || timeZoneID.equals(""))
{
timeZoneID = TimeZone.getDefault().getID();
}
Locale clientLocale = NLSUtil.getClientLocale(request);
SimpleDateFormat dateFormat =
(SimpleDateFormat)DateFormat.getDateInstance(DateFormat.MEDIUM,
clientLocale);
//if the timeZoneID is not valid,then it will set the GMT timezone
dateFormat.setTimeZone(TimeZone.getTimeZone(timeZoneID));
SimpleDateFormat timeFormat =
(SimpleDateFormat)DateFormat.getTimeInstance(DateFormat.MEDIUM,
clientLocale);
timeFormat.setTimeZone(TimeZone.getTimeZone(timeZoneID));
nlsParams = new Object[1];
nlsParams[0] = dateFormat.toLocalizedPattern();
String ALERT_INVALID_END_DATE = MessageFormat.format(
rb.getString(
ServicesMsgID.ALERT_INVALID_END_DATE
), nlsParams);
String ALERT_INVALID_START_DATE = MessageFormat.format(
rb.getString(
ServicesMsgID.ALERT_INVALID_START_DATE
), nlsParams);
nlsParams = new Object[1];
nlsParams[0] = new Integer(ServiceConstants.MAX_PRE_NO_YEARS + 1);
String ALERT_DATE_RANGE = MessageFormat.format(
rb.getString(
ServicesMsgID.ALERT_DATE_RANGE
), nlsParams);
int windowHeight = 460;
String errorMessage = "";
String event = "";
//String sDate = "";
//String eDate = "";
String sDate2 = "";
String eDate2 = "";
java.util.Date stDate = null;
java.util.Date edDate = null;
SimpleDateFormat internalDateFormat =
new SimpleDateFormat(ServiceConstants.INTERNAL_DATE_FORMAT);
int submitForm = 1;
String selTimeRange = "";
int selectDate1 = 1;
if(getRequestParam(request,"event") != null)
{
event = (String)getRequestParam(request,"event");
}
if(event.equals("validate"))
{
sDate = (String)getRequestParam(request,"date1");
eDate = (String)getRequestParam(request,"date2");
if(sDate == null || sDate.equals(""))
{
errorMessage = errorMessage +
rb.getString(ServicesMsgID.ALERT_START_DATE) + ";";
submitForm = 0;
windowHeight = windowHeight + 100;
}
else
{
try
{
sDate2 = SLUtil.getInternalDate(request, sDate);
sDate = SLUtil.getClientLocaleDate(request, sDate2);
}
catch(ParseException e)
{
submitForm = 0;
errorMessage = errorMessage + ALERT_INVALID_START_DATE + ";";
windowHeight = windowHeight + 100;
sDate = (String)getRequestParam(request,"date1");
}
}
if(eDate == null || eDate.equals(""))
{
if(submitForm == 1)
{
eDate = dateFormat.format(new java.util.Date());
eDate2 = SLUtil.getInternalDate(request, eDate);
eDate = SLUtil.getClientLocaleDate(request, eDate2);
}
else
{
errorMessage = errorMessage +
rb.getString(ServicesMsgID.ALERT_END_DATE) + ";";
submitForm = 0;
windowHeight = windowHeight + 35;
}
}
else
{
try
{
eDate2 = SLUtil.getInternalDate(request, eDate);
eDate = SLUtil.getClientLocaleDate(request, eDate2);
}
catch(ParseException e)
{
if(submitForm == 1)
{
selectDate1 = 0;
}
submitForm = 0;
errorMessage = errorMessage + ALERT_INVALID_END_DATE + ";";
if(windowHeight == 560)
{
windowHeight = windowHeight + 35;
}
else
{
windowHeight = windowHeight + 100;
}
eDate = (String)getRequestParam(request,"date2");
}
}
if(sDate2 != null && eDate2 != null && submitForm == 1)
{
stDate = internalDateFormat.parse(sDate2);
edDate = internalDateFormat.parse(eDate2);
if(edDate.before(stDate) || edDate.equals(stDate))
{
submitForm = 0;
errorMessage = errorMessage +
rb.getString(ServicesMsgID.ALERT_END_GREATER_THAN_START) + ";";
windowHeight = windowHeight + 100;
selectDate1 = 0;
}
}
if(submitForm == 1)
{
if(stDate != null && edDate != null)
{
if((edDate.getTime()-stDate.getTime())/1000/60/60/24
> ServiceConstants.MAX_PRE_NO_YEARS*365.25)
{
submitForm = 0;
errorMessage = errorMessage + ALERT_DATE_RANGE + ";";
windowHeight = windowHeight + 100;
selectDate1 = 0;
}
}
}
if(submitForm == 1)
{
selTimeRange = "3:" + sDate2 + ":" + eDate2;
}
}
//max days
nlsParams[0] = new Integer(
(new Double(Math.floor(
365.25*ServiceConstants.MAX_PRE_NO_YEARS))).intValue()
);
String ALERT_PREV_DAYS_RANGE = MessageFormat.format(
rb.getString(
ServicesMsgID.ALERT_PREV_DAYS_RANGE
), nlsParams);
//max weeks
nlsParams = new Object[1];
nlsParams[0] = new Integer(52*ServiceConstants.MAX_PRE_NO_YEARS);
String ALERT_PREV_WEEKS_RANGE = MessageFormat.format(
rb.getString(
ServicesMsgID.ALERT_PREV_WEEKS_RANGE
), nlsParams);
//max months
nlsParams = new Object[1];
nlsParams[0] = new Integer(12*ServiceConstants.MAX_PRE_NO_YEARS);
String ALERT_PREV_MONTHS_RANGE = MessageFormat.format(
rb.getString(
ServicesMsgID.ALERT_PREV_MONTHS_RANGE
), nlsParams);
//max years
nlsParams = new Object[1];
nlsParams[0] = new Integer(ServiceConstants.MAX_PRE_NO_YEARS);
String ALERT_PREV_YEARS_RANGE = MessageFormat.format(
rb.getString(
ServicesMsgID.ALERT_PREV_YEARS_RANGE
), nlsParams);
//System.out.println("Prev Years : " + ALERT_PREV_YEARS_RANGE);
//System.out.println("***" + rb.getString(ServicesMsgID.ALERT_PREV_YEARS_RANGE) + "***");
//date range
nlsParams = new Object[1];
nlsParams[0] = new Integer(ServiceConstants.MAX_PRE_NO_YEARS);
String ALERT_OLD_DATE = MessageFormat.format(
rb.getString(
ServicesMsgID.ALERT_OLD_DATE
), nlsParams);
nlsParams = new Object[1];
nlsParams[0] = (TimeZone.getTimeZone(timeZoneID)).getDisplayName(
false, TimeZone.SHORT, clientLocale);
String POPUP_NOTE = MessageFormat.format(
rb.getString(ServicesMsgID.POPUP_NOTE), nlsParams);
String dateLast_7 = "0:1";
String datePrev_7 = "1:7:0";
String datePrev_1 = "1:1:0";
String dateCal_Week = "2:0";
ArrayList tempDate = new ArrayList();
Calendar genCal = Calendar.getInstance();
String startDate = null;
String endDate = null;
Object lastDates[] = new Object[4];
Object prevDates[] = new Object[2];
Object calDates[] = new Object[3];
Object custDates[] = new Object[4];
Object maxYears[] = new Object[1];
String strDate = null;
String strTime = null;
String strDate_1 = null;
String strTime_1 = null;
String strDate_7 = null;
String strTime_7 = null;
String strDate_Week = null;
String strTime_Week = null;
tempDate = SLDBHelper.getDates(dateLast_7, timeZoneID);
genCal.setTime(new java.util.Date(((Long)tempDate.get(0)).longValue()));
strDate_7 = dateFormat.format(genCal.getTime());
genCal.setTime(new java.util.Date(((Long)tempDate.get(1)).longValue()));
strTime = timeFormat.format(genCal.getTime());
strDate = dateFormat.format(genCal.getTime());
lastDates[0] = strTime;
lastDates[1] = strDate_7;
lastDates[2] = strTime;
lastDates[3] = strDate;
tempDate = SLDBHelper.getDates(datePrev_7, timeZoneID);
genCal.setTime(new java.util.Date( ((Long)tempDate.get(0)).longValue()-24*3600*1000));
strDate_7 = dateFormat.format(genCal.getTime());
genCal.setTime(new java.util.Date(((Long)tempDate.get(1)).longValue()-24*3600*1000));
strDate_1 = dateFormat.format(genCal.getTime());
genCal.set(genCal.HOUR_OF_DAY,23);
genCal.set(genCal.MINUTE,59);
genCal.set(genCal.SECOND,59);
strTime_1 = timeFormat.format(genCal.getTime());
prevDates[0] = strDate_7;
//prevDates[1] = strTime_1;
prevDates[1] = strDate_1;
tempDate = SLDBHelper.getDates(dateCal_Week, timeZoneID);
genCal.setTime(new java.util.Date(((Long)tempDate.get(0)).longValue()-24*3600*1000));
strDate_Week = dateFormat.format(genCal.getTime());
genCal.setTime(new java.util.Date(((Long)tempDate.get(1)).longValue()));
strDate_1 = dateFormat.format(genCal.getTime());
calDates[0] = strDate_Week;
calDates[1] = strTime;
calDates[2] = strDate;
java.util.Date dtNow = Calendar.getInstance().getTime();
java.util.Date dtOld =
new java.util.Date(dtNow.getTime() - 1000*60*60*24*7);
custDates[0] = (String)dateFormat.format(dtOld);
custDates[1] = (String)dateFormat.format(dtNow);
custDates[2] = (String)dateFormat.format(dtOld);
custDates[3] = (String)dateFormat.format(dtNow);
maxYears[0] = (new Integer(ServiceConstants.MAX_PRE_NO_YEARS)).toString();
String lastInlineTxt =
MessageFormat.format( rb.getString(ServicesMsgID.CURRTIME_INLINETEXT),
lastDates);
String prevInlineTxt =
MessageFormat.format( rb.getString(ServicesMsgID.PREVTIME_INLINETEXT),
prevDates);
String calInlineTxt =
MessageFormat.format( rb.getString(ServicesMsgID.CALTIME_INLINETEXT),
calDates);
String custInlineTxt =
MessageFormat.format( rb.getString(ServicesMsgID.CUSTOMTIME_INLINETEXT),
custDates);
String timerange_inlinetext =
MessageFormat.format( rb.getString(ServicesMsgID.TIMERANGE_INLINETEXT),
maxYears);
String tpTimerange_inlinetext =
MessageFormat.format( rb.getString(ServicesMsgID.TP_TIMERANGE_INLINETEXT),
maxYears);
request.setAttribute("lastInlineTxt",lastInlineTxt);
request.setAttribute("prevInlineTxt",prevInlineTxt);
request.setAttribute("calInlineTxt",calInlineTxt);
request.setAttribute("custInlineTxt",custInlineTxt);
request.setAttribute("timerange_inlinetext",timerange_inlinetext);
request.setAttribute("tpTimerange_inlinetext",tpTimerange_inlinetext);
String prevTxtBox = (String)getRequestParam(request,"prevTxtBox");
//Expected value for prevTxtBox is 5 chars (user can enter only 5 chars thru UI)
//if it is more than 5 chars,then the prevTxtBox param is passed externally
if(prevTxtBox!=null && prevTxtBox.length()>5){
prevTxtBox = "";
}
%>
<%if(tpFlag){%>
<%}else{%>
<%}%>
<%if(!tpFlag){%>
<%}else{%>
<%}%>
<%
String selIndex = "0";
String lastChoice = "1";
if(tpFlag){ lastChoice="0"; }
//[to format the internal dates passed by the window.opener
//while opening the winow
if(!resetSelTimeValue && !sDate.equals("")){
try{
sDate= SLUtil.getClientLocaleDate(request,sDate);
}
catch(ParseException e)
{
submitForm = 0;
errorMessage = errorMessage + ALERT_INVALID_START_DATE + ";";
windowHeight = windowHeight + 100;
}
try{
eDate= SLUtil.getClientLocaleDate(request,eDate);
}
catch(ParseException e)
{
submitForm = 0;
errorMessage = errorMessage + ALERT_INVALID_END_DATE + ";";
windowHeight = windowHeight + 100;
}
}
//]
String dtFormatStr = "("+rb.getString(ServicesMsgID.DATE_FORMAT_TXT)
+" "+dateFormat.toLocalizedPattern()+")";
String date1 = sDate;
String date2 = eDate;
if(errorMessage.equals("") && getRequestParam(request,"errorMsg")!=null){
errorMessage = (String)getRequestParam(request,"errorMsg");
}
if(errorMessage != null && !errorMessage.equals("")){
ArrayList errorList = SLUtil.getList(errorMessage, ";");
errorMessage = (String)errorList.get(0);
selIndex = (String)getRequestParam(request,"selIndex");
lastChoice = (String)getRequestParam(request,"lastChoice");
%>
<% for(int i=0; i< errorList.size(); i++){ %>
<% } %>
<%}
//render timezone list box
if (tpFlag){
%>
<%for(int i=0; i
<%}%>
<%}%>
">
">