use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class TimeConditionHelper method getTime.
private boolean getTime(ConditionOpViewBeanBase viewBean, boolean bStart, Map values) {
AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
boolean valid = false;
String hours = (bStart) ? (String) propModel.getValue(STARTHOUR) : (String) propModel.getValue(ENDHOUR);
String minutes = (bStart) ? (String) propModel.getValue(STARTMINUTE) : (String) propModel.getValue(ENDMINUTE);
String session = (bStart) ? (String) propModel.getValue(STARTSESSION) : (String) propModel.getValue(ENDSESSION);
hours = hours.trim();
minutes = minutes.trim();
if ((hours.length() > 0) && (minutes.length() > 0)) {
try {
int hr = Integer.parseInt(hours);
int mm = Integer.parseInt(minutes);
if (session.equals("pm") && (hr < 12)) {
hr += 12;
}
if ((hr >= 0) && (hr <= 23) && (mm >= 0) && (mm <= 59)) {
hours = (hr < 10) ? "0" + hr : Integer.toString(hr);
minutes = (mm < 10) ? "0" + mm : Integer.toString(mm);
Set set = new HashSet();
set.add(hours + ":" + minutes);
values.put((bStart) ? SimpleTimeCondition.START_TIME : SimpleTimeCondition.END_TIME, set);
valid = true;
} else {
viewBean.setErrorMessage((bStart) ? "policy.condition.time.invalid.starttime" : "policy.condition.time.invalid.endtime");
}
} catch (NumberFormatException e) {
viewBean.setErrorMessage((bStart) ? "policy.condition.time.invalid.starttime" : "policy.condition.time.invalid.endtime");
}
} else {
valid = true;
}
return valid;
}
use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class TimeConditionHelper method getDay.
private void getDay(ConditionOpViewBeanBase viewBean, boolean bStart, Map values) {
AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
String day = (bStart) ? (String) propModel.getValue(STARTDAY) : (String) propModel.getValue(ENDDAY);
if (day.length() > 0) {
Set set = new HashSet();
set.add(day);
values.put((bStart) ? SimpleTimeCondition.START_DAY : SimpleTimeCondition.END_DAY, set);
}
}
use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class TimeConditionHelper method setDate.
public void setDate(ConditionOpViewBeanBase viewBean, boolean bStart, String strDate, AMModel model) {
TimeConditionHelper.DATE_FORMAT = model.getLocalizedString("policy.condition.time.dateformat");
if (TimeConditionHelper.DATE_FORMAT == null || TimeConditionHelper.DATE_FORMAT.length() == 0)
TimeConditionHelper.DATE_FORMAT = "MM/dd/yyyy";
AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
propModel.setValue((bStart) ? STARTDATE : ENDDATE, formatDate(strDate));
}
use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class TimeConditionHelper method getTimeZoneValue.
private boolean getTimeZoneValue(ConditionOpViewBeanBase viewBean, Map values) {
boolean valid = false;
AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
String radio = (String) propModel.getValue(RADIOTIMEZONE);
if ((radio != null) && (radio.length() > 0)) {
String tz = null;
if (radio.equals("standard")) {
tz = (String) propModel.getValue(STANDARDTIMEZONE);
valid = true;
} else {
tz = (String) propModel.getValue(CUSTOMTIMEZONE);
if (RFC_822_PATTERN.matcher(tz).matches()) {
tz = getNormalizedTimeZone("GMT" + tz);
valid = true;
} else {
valid = isValidTimeZone(tz);
}
if (!valid) {
viewBean.setErrorMessage("policy.condition.time.invalid.timezone");
}
}
if (valid) {
Set set = new HashSet();
set.add(tz);
values.put(SimpleTimeCondition.ENFORCEMENT_TIME_ZONE, set);
}
} else {
valid = true;
}
return valid;
}
use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.
the class TimeConditionHelper method setDay.
public void setDay(ConditionOpViewBeanBase viewBean, boolean bStart, String strDay) {
if ((strDay != null) && (strDay.length() > 0)) {
AMPropertySheetModel propModel = viewBean.getPropertySheetModel();
propModel.setValue((bStart) ? STARTDAY : ENDDAY, strDay);
}
}
Aggregations