use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class ConditionTypeManager method getCondition.
/**
* Returns an instance of the <code>Condition</code>
* given the condition type name.
*
* @param conditionType condition type name.
* @return an instance of the <code>Condition</code>
* given the condition type name.
* @throws NameNotFoundException if the <code>Condition</code> for the
* <code>conditionType</code> name is not found
* @throws PolicyException for any other abnormal condition
*/
public Condition getCondition(String conditionType) throws NameNotFoundException, PolicyException {
PluginSchema ps = PolicyManager.getPluginSchema(CONDITION, conditionType);
if (ps == null) {
throw (new NameNotFoundException(ResBundleUtils.rbName, "invalid_condition", null, conditionType, PolicyException.USER_COLLECTION));
}
// Construct the object
Condition condition = null;
try {
String className = ps.getClassName();
condition = (Condition) Class.forName(className).newInstance();
} catch (Exception e) {
throw (new PolicyException(e));
}
return (condition);
}
use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class ConditionOpViewBeanBase method createCondition.
protected Condition createCondition() throws ModelControlException, AMConsoleException {
Condition condition = null;
String conditionType = (String) getPageSessionAttribute(PG_SESSION_CONDITION_TYPE);
String conditionName = getConditionName();
Map values = getValues(conditionType);
if (conditionName != null) {
if (values != null) {
condition = createCondition(conditionType, values);
}
}
return condition;
}
use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class ConditionAddViewBean method handleButton2Request.
/**
* Handles create policy's condition request.
*
* @param event Request invocation event
*/
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
try {
Condition condition = createCondition();
if (condition != null) {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
String name = (String) propertySheetModel.getValue(CONDITION_NAME);
policy.addCondition(name, condition);
backTrail();
forwardToPolicyViewBean();
} else {
forwardTo();
}
} catch (NameAlreadyExistsException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
forwardTo();
} catch (InvalidNameException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
forwardTo();
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
}
use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class ConditionEditViewBean 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);
values = condition.getProperties();
} catch (NameNotFoundException e) {
debug.warning("ConditionEditViewBean.getDefaultValues", e);
} catch (AMConsoleException e) {
debug.warning("ConditionEditViewBean.getDefaultValues", e);
}
return values;
}
use of com.sun.identity.policy.interfaces.Condition in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method handleTblConditionsEditLinkRequest.
public void handleTblConditionsEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
PolicyModel model = (PolicyModel) getModel();
String name = hexToString((String) getDisplayFieldValue(TBL_CONDITIONS_ACTION_HREF));
setPageSessionAttribute(ConditionEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
setPageSessionAttribute(ConditionEditViewBean.EDIT_CONDITION_NAME, name);
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
Condition condition = policy.getCondition(name);
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String conditionType = model.getConditionTypeName(realmName, condition);
String viewBeanURL = model.getConditionViewBeanURL(realmName, conditionType);
unlockPageTrail();
if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
forwardToConditionURL(viewBeanURL, name, conditionType, realmName, "edit");
} else {
forwardToConditionEditViewBean(model, realmName, name, conditionType);
}
} catch (NameNotFoundException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
forwardTo();
} catch (AMConsoleException e) {
debug.warning("PolicyOpViewBeanBase.handleTblConditionsButtonDeleteRequest", e);
redirectToStartURL();
}
}
Aggregations