use of com.sun.identity.console.policy.model.CachedPolicy in project OpenAM by OpenRock.
the class PMDefaultTimeConditionEditViewBean method getDefaultValues.
protected Map getDefaultValues() {
Map values = null;
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
String conditionName = (String) getPageSessionAttribute(ConditionOpViewBeanBase.PG_SESSION_CONDITION_NAME);
Condition condition = policy.getCondition(conditionName);
Map map = condition.getProperties();
for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
String propName = (String) iter.next();
Set val = (Set) map.get(propName);
if (propName.equals(SimpleTimeCondition.START_DATE)) {
String strDate = (String) val.iterator().next();
helper.setDate(this, true, strDate, getModel());
} else if (propName.equals(SimpleTimeCondition.END_DATE)) {
String strDate = (String) val.iterator().next();
helper.setDate(this, false, strDate, getModel());
} else if (propName.equals(SimpleTimeCondition.START_TIME)) {
String strTime = (String) val.iterator().next();
helper.setTime(this, true, strTime);
} else if (propName.equals(SimpleTimeCondition.END_TIME)) {
String strTime = (String) val.iterator().next();
helper.setTime(this, false, strTime);
} else if (propName.equals(SimpleTimeCondition.START_DAY)) {
String strDay = (String) val.iterator().next();
helper.setDay(this, true, strDay);
} else if (propName.equals(SimpleTimeCondition.END_DAY)) {
String strDay = (String) val.iterator().next();
helper.setDay(this, false, strDay);
} else if (propName.equals(SimpleTimeCondition.ENFORCEMENT_TIME_ZONE)) {
String strTz = (String) val.iterator().next();
helper.setTimeZone(this, canModify, strTz);
}
}
} catch (NameNotFoundException e) {
debug.warning("ConditionEditViewBean.getDefaultValues", e);
} catch (AMConsoleException e) {
debug.warning("ConditionEditViewBean.getDefaultValues", e);
}
//Yes, we are returning null;
return values;
}
use of com.sun.identity.console.policy.model.CachedPolicy in project OpenAM by OpenRock.
the class PolicyReferralEditViewBean method getBreadCrumbDisplayName.
protected String getBreadCrumbDisplayName() {
PolicyModel model = (PolicyModel) getModel();
try {
CachedPolicy cachedPolicy = getCachedPolicy();
String[] arg = { cachedPolicy.getTrackPolicyName() };
return MessageFormat.format(model.getLocalizedString("breadcrumbs.editPolicy"), (Object[]) arg);
} catch (AMConsoleException e) {
debug.warning("PolicyReferralEditViewBean.getBreadCrumbDisplayName", e);
// Bread Crumb will not be set if cached policy cannot be located.
return "";
}
}
use of com.sun.identity.console.policy.model.CachedPolicy in project OpenAM by OpenRock.
the class PolicyReferralEditViewBean method handleButton1Request.
/**
* Handles create policy request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
try {
if (reconstructPolicy()) {
// error message set in PolicyOpViewBeanBase
} else {
CachedPolicy cachedPolicy = getCachedPolicy();
PolicyModel model = (PolicyModel) getModel();
try {
model.replacePolicy(currentRealm, cachedPolicy.getPolicy());
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.modified.message");
cachedPolicy.setPolicyModified(false);
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
forwardTo();
} catch (AMConsoleException e) {
debug.warning("PolicyReferralEditViewBean.handleButton1Request", e);
redirectToStartURL();
}
}
use of com.sun.identity.console.policy.model.CachedPolicy in project OpenAM by OpenRock.
the class PolicyReferralEditViewBean method handleButton2Request.
/**
* Handles reset request.
*
* @param event Request invocation event
*/
public void handleButton2Request(RequestInvocationEvent event) {
PolicyModel model = (PolicyModel) getModel();
String cacheID = (String) getPageSessionAttribute(ProfileViewBeanBase.PG_SESSION_POLICY_CACHE_ID);
try {
CachedPolicy cachedPolicy = model.getCachedPolicy(cacheID);
String policyName = cachedPolicy.getTrackPolicyName();
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
try {
cacheID = model.cachePolicy(curRealm, policyName);
setPageSessionAttribute(PolicyOpViewBeanBase.PG_SESSION_POLICY_CACHE_ID, cacheID);
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
} catch (AMConsoleException e) {
debug.warning("PolicyReferralEditViewBean.handleButton2Request", e);
redirectToStartURL();
}
}
use of com.sun.identity.console.policy.model.CachedPolicy in project OpenAM by OpenRock.
the class PolicyNormalAddViewBean method handleButton1Request.
/**
* Handles create policy request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
try {
reconstructPolicy();
CachedPolicy cachedPolicy = getCachedPolicy();
PolicyModel model = (PolicyModel) getModel();
String name = cachedPolicy.getPolicy().getName();
if (name.equals(model.getLocalizedString("policy.create.name"))) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getLocalizedString("policy.name.change"));
forwardTo();
} else {
try {
model.createPolicy(currentRealm, cachedPolicy.getPolicy());
backTrail();
forwardToPolicyViewBean();
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
}
} catch (AMConsoleException e) {
redirectToStartURL();
}
}
Aggregations