use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method populateRulesTable.
protected void populateRulesTable() throws AMConsoleException {
tblRulesModel.clearAll();
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
Set ruleNames = policy.getRuleNames();
if ((ruleNames != null) && !ruleNames.isEmpty()) {
PolicyModel model = (PolicyModel) getModel();
Map localizedSvcTypeNames = model.getServiceTypeNames();
boolean firstEntry = true;
for (Iterator iter = ruleNames.iterator(); iter.hasNext(); ) {
if (firstEntry) {
firstEntry = false;
} else {
tblRulesModel.appendRow();
}
try {
String name = (String) iter.next();
Rule rule = policy.getRule(name);
tblRulesModel.setValue(TBL_RULES_DATA_NAME, name);
tblRulesModel.setValue(TBL_RULES_DATA_TYPE, localizedSvcTypeNames.get(rule.getServiceTypeName()));
tblRulesModel.setValue(TBL_RULES_ACTION_HREF, stringToHex(name));
} catch (NameNotFoundException e) {
debug.warning("PolicyOpViewBeanBase.populateRulesTable", e);
}
}
}
}
use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method handleTblRulesEditLinkRequest.
/**
* Handles edit rule request.
*
* @param event Request Invocation Event.
*/
public void handleTblRulesEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
PolicyModel model = (PolicyModel) getModel();
String name = hexToString((String) getDisplayFieldValue(TBL_RULES_ACTION_HREF));
setPageSessionAttribute(RuleEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
setPageSessionAttribute(RuleEditViewBean.EDIT_RULE_NAME, name);
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
Rule rule = policy.getRule(name);
RuleEditViewBean vb = null;
String resName = rule.getResourceName();
if ((resName == null) || (resName.length() == 0)) {
vb = (RuleNoResourceEditViewBean) getViewBean(RuleNoResourceEditViewBean.class);
setPageSessionAttribute(RuleOpViewBeanBase.WITH_RESOURCE, Boolean.FALSE);
} else {
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String serviceType = rule.getServiceTypeName();
if (model.canCreateNewResource(realmName, serviceType)) {
vb = (RuleEditViewBean) getViewBean(RuleEditViewBean.class);
} else {
vb = (RuleEditViewBean) getViewBean(RuleWithPrefixEditViewBean.class);
}
setPageSessionAttribute(RuleOpViewBeanBase.WITH_RESOURCE, Boolean.TRUE);
}
unlockPageTrail();
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
} catch (NameNotFoundException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
forwardTo();
} catch (AMConsoleException e) {
debug.warning("PolicyOpViewBeanBase.handleTblRulesEditLinkRequest", e);
redirectToStartURL();
}
}
use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class RuleAddViewBean method handleButton2Request.
/**
* Handles create policy request.
*
* @param event Request invocation event
*/
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
Rule rule = createRule();
if (rule != null) {
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
policy.addRule(rule);
backTrail();
cachedPolicy.setPolicyModified(true);
forwardToPolicyViewBean();
} 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) {
debug.warning("RuleAddViewBean.handleButton2Request", e);
redirectToStartURL();
}
} else {
forwardTo();
}
}
use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class RuleEditViewBean method handleButton1Request.
/**
* Handles create policy request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
boolean forwarded = false;
Rule rule = createRule();
if (rule != null) {
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
String origRuleName = (String) getPageSessionAttribute(EDIT_RULE_NAME);
policy.removeRule(origRuleName);
policy.addRule(rule);
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.rule.updated");
cachedPolicy.setPolicyModified(true);
} catch (NameAlreadyExistsException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (InvalidNameException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (AMConsoleException e) {
debug.warning("RuleEditViewBean.handleButton1Request", e);
redirectToStartURL();
forwarded = true;
}
}
if (!forwarded) {
forwardTo();
}
}
use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class RuleEditViewBean method isActionSelected.
public boolean isActionSelected(ActionSchema as) {
boolean selected = false;
if (actionValues != null) {
Set values = (Set) actionValues.get(as.getName());
selected = (values != null) && !values.isEmpty();
} else {
try {
Rule rule = getRule();
Set actionNames = rule.getActionNames();
selected = (actionNames != null) && actionNames.contains(as.getName());
} catch (NameNotFoundException e) {
selected = false;
} catch (AMConsoleException e) {
debug.warning("RuleEditViewBean.isActionSelected", e);
selected = false;
}
}
return selected;
}
Aggregations