use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class AgentProfileViewBean method handleButton1Request.
/**
* Handles Save button click.
*
* @param event Request Invocation Event.
* @throws ModelControlException if cannot access to framework model.
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
boolean bRefresh = false;
AgentsModel model = (AgentsModel) getModel();
String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
String type = getAgentType();
String choice = (String) getPageSessionAttribute(AgentsViewBean.LOCAL_OR_NOT);
try {
Map values = getFormValues();
if (checkAgentType(type)) {
if (!isGroup && !is2dot2Agent() && !isAgentAuthenticator() && (choice != null) && !choice.equals(AgentsViewBean.PROP_LOCAL)) {
for (Iterator i = inheritedPropertyNames.iterator(); i.hasNext(); ) {
values.remove(i.next());
}
if (type.equals(AgentsViewBean.DEFAULT_ID_TYPE)) {
Iterator itr = values.keySet().iterator();
while (itr.hasNext()) {
String name = (String) itr.next();
Set v = (Set) values.get(name);
if ((v != null) && !v.isEmpty() && (v.size() == 1)) {
Iterator itr2 = v.iterator();
while (itr2.hasNext()) {
String subv = (String) itr2.next();
subv.trim();
if (subv.length() == 0) {
values.put(name, null);
break;
}
}
}
}
}
}
} else {
if (!isGroup && !is2dot2Agent() && !isAgentAuthenticator()) {
for (Iterator i = inheritedPropertyNames.iterator(); i.hasNext(); ) {
values.remove(i.next());
}
}
}
model.setAttributeValues(universalId, values);
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
if (checkAgentType(type)) {
if (!isGroup && !is2dot2Agent() && isFirstTab() && !isAgentAuthenticator() && (choice != null) && !choice.equals(AgentsViewBean.PROP_LOCAL)) {
String agentGroup = getDisplayFieldStringValue(CHILD_AGENT_GROUP);
bRefresh = model.setGroup(curRealm, universalId, agentGroup);
String status = getDisplayFieldStringValue(AgentsViewBean.ATTR_CONFIG_REPO);
if (status.equals("local")) {
setPageSessionAttribute(AgentsViewBean.LOCAL_OR_NOT, AgentsViewBean.PROP_LOCAL);
bRefresh = true;
}
}
} else {
if (!isGroup && !is2dot2Agent() && !isAgentAuthenticator() && isFirstTab()) {
String agentGroup = getDisplayFieldStringValue(CHILD_AGENT_GROUP);
bRefresh = model.setGroup(curRealm, universalId, agentGroup);
}
}
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
bRefresh = false;
}
if (bRefresh) {
setPageSessionAttribute(UPDATED_PROFILE, "true");
AMPostViewBean vb = (AMPostViewBean) getViewBean(AMPostViewBean.class);
passPgSessionMap(vb);
String url = this.getDefaultDisplayURL();
int idx = url.indexOf("/", 1);
url = ".." + url.substring(idx);
vb.setTargetViewBeanURL(url);
vb.forwardTo(getRequestContext());
} else {
forwardTo();
}
}
use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class AgentProfileViewBean method beginBtnInheritDisplay.
/**
* Disables inheritance setting button if the agent does not belong
* a group.
*
* @param event Child Display Event.
* @return <code>true</code> if the agent belongs to a group.
*/
public boolean beginBtnInheritDisplay(ChildDisplayEvent event) {
AgentsModel model = (AgentsModel) getModel();
String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
disableButton(BTN_INHERIT, false);
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
try {
String groupId = model.getAgentGroup(curRealm, universalId);
if ((groupId == null) || (groupId.trim().length() == 0)) {
disableButton(BTN_INHERIT, true);
}
} catch (AMConsoleException ex) {
disableButton(BTN_INHERIT, true);
}
return !isGroup;
}
use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class AgentsViewBean method handleTblButtonGroupDeleteRequest.
/**
* Deletes agent groups.
*
* @param event Request Invocation Event.
* @throws ModelControlException if table model cannot be restored.
*/
public void handleTblButtonGroupDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
CCActionTable table = (CCActionTable) getChild(TBL_SEARCH_GROUP);
table.restoreStateData();
Integer[] selected = tblGroupModel.getSelectedRows();
Set names = new HashSet(selected.length * 2);
SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
Map mapCache = (Map) szCache.getSerializedObj();
List cache = (List) mapCache.get(CACHE_AGENT_GROUPS);
for (int i = 0; i < selected.length; i++) {
names.add((String) cache.get(selected[i].intValue()));
}
try {
AgentsModel model = (AgentsModel) getModel();
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
model.deleteAgentGroups(curRealm, names);
if (selected.length == 1) {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("agent.groups.message.deleted"));
} else {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("agent.groups.message.deleted.pural"));
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class AgentsViewBean method addAgentsTab.
private CCNavNode addAgentsTab(int idx) {
AgentsModel model = (AgentsModel) getModel();
AMViewConfig config = AMViewConfig.getInstance();
return config.addAgentTabs(tabModel, model, idx);
}
use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class AgentsViewBean method handleTblButtonDeleteRequest.
/**
* Deletes agents.
*
* @param event Request Invocation Event.
* @throws ModelControlException if table model cannot be restored.
*/
public void handleTblButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
CCActionTable table = (CCActionTable) getChild(TBL_SEARCH);
table.restoreStateData();
Integer[] selected = tblModel.getSelectedRows();
Set names = new HashSet(selected.length * 2);
SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
Map mapCache = (Map) szCache.getSerializedObj();
List cache = (List) mapCache.get(CACHE_AGENTS);
for (int i = 0; i < selected.length; i++) {
names.add((String) cache.get(selected[i].intValue()));
}
try {
AgentsModel model = (AgentsModel) getModel();
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
model.deleteAgents(curRealm, names);
if (selected.length == 1) {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("agents.message.deleted"));
} else {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("agents.message.deleted.pural"));
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
Aggregations