use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class AgentsViewBean method getAgentNames.
private void getAgentNames() {
AgentsModel model = (AgentsModel) getModel();
String filter = ((String) getDisplayFieldValue(TF_FILTER));
String gfilter = ((String) getDisplayFieldValue(TF_GROUP_FILTER));
if ((filter == null) || (filter.length() == 0)) {
filter = "*";
setDisplayFieldValue(TF_FILTER, "*");
} else {
filter = filter.trim();
}
if ((gfilter == null) || (gfilter.length() == 0)) {
gfilter = "*";
setDisplayFieldValue(TF_GROUP_FILTER, "*");
} else {
gfilter = gfilter.trim();
}
// this is to faciliate combined types.
String agentType = getDisplayIDType();
AMViewConfig cfg = AMViewConfig.getInstance();
Set agentTypes = cfg.getCombineAgentTypes(agentType);
if (agentTypes == null) {
agentTypes = new HashSet(2);
agentTypes.add(agentType);
} else {
supportedTypes.addAll(agentTypes);
}
try {
Set agents = new HashSet();
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
int errorCode = model.getAgentNames(curRealm, agentTypes, filter, agents);
switch(errorCode) {
case IdSearchResults.SIZE_LIMIT_EXCEEDED:
setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", "message.sizelimit.exceeded");
break;
case IdSearchResults.TIME_LIMIT_EXCEEDED:
setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", "message.timelimit.exceeded");
break;
}
Set agentGroups = new HashSet();
errorCode = model.getAgentGroupNames(curRealm, agentTypes, gfilter, agentGroups);
switch(errorCode) {
case IdSearchResults.SIZE_LIMIT_EXCEEDED:
setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", "message.sizelimit.exceeded");
break;
case IdSearchResults.TIME_LIMIT_EXCEEDED:
setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", "message.timelimit.exceeded");
break;
}
Map results = new HashMap(4);
results.put(CACHE_AGENTS, agents);
results.put(CACHE_AGENT_GROUPS, agentGroups);
populateTableModel(results);
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
CCButton b = (CCButton) getChild(TBL_BUTTON_ADD);
b.setDisabled(true);
b = (CCButton) getChild(TBL_BUTTON_ADD_GROUP);
b.setDisabled(true);
}
}
use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class AgentsViewBean method populateTableModel.
private void populateTableModel(Map map) {
tblModel.clearAll();
tblGroupModel.clearAll();
SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
if ((map != null) && !map.isEmpty()) {
// set the paging size
AgentsModel model = (AgentsModel) getModel();
tblModel.setMaxRows(model.getPageSize());
tblGroupModel.setMaxRows(model.getPageSize());
Map mapCache = new HashMap(4);
Collection agents = (Collection) map.get(CACHE_AGENTS);
if ((agents != null) && !agents.isEmpty()) {
int counter = 0;
boolean firstEntry = true;
List cacheAgents = new ArrayList(agents.size());
for (Iterator iter = agents.iterator(); iter.hasNext(); ) {
AMIdentity entity = (AMIdentity) iter.next();
if (firstEntry) {
firstEntry = false;
} else {
tblModel.appendRow();
}
String name = AMFormatUtils.getIdentityDisplayName(model, entity);
tblModel.setSelectionVisible(counter++, true);
String universalId = IdUtils.getUniversalId(entity);
tblModel.setValue(TBL_DATA_NAME, name);
tblModel.setValue(TBL_DATA_UNIVERSALNAME, universalId);
tblModel.setValue(TBL_DATA_ACTION_HREF, stringToHex(universalId));
if (centralizable) {
if (model.isCentralized(universalId)) {
tblModel.setValue(TBL_DATA_LOCAL, "table.agents.data.repo.centralized");
} else {
tblModel.setValue(TBL_DATA_LOCAL, "table.agents.data.repo.localized");
}
} else if (combinedType) {
try {
tblModel.setValue(TBL_DATA_TYPE, model.getLocalizedString("agenttype." + model.getAgentType(entity)));
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
}
}
cacheAgents.add(universalId);
}
mapCache.put(CACHE_AGENTS, cacheAgents);
}
Collection agentgroups = (Collection) map.get(CACHE_AGENT_GROUPS);
if ((agentgroups != null) && !agentgroups.isEmpty()) {
int counter = 0;
boolean firstEntry = true;
List cacheAgentGroups = new ArrayList(agentgroups.size());
for (Iterator iter = agentgroups.iterator(); iter.hasNext(); ) {
AMIdentity entity = (AMIdentity) iter.next();
if (firstEntry) {
firstEntry = false;
} else {
tblGroupModel.appendRow();
}
String name = AMFormatUtils.getIdentityDisplayName(model, entity);
tblGroupModel.setSelectionVisible(counter++, true);
String universalId = IdUtils.getUniversalId(entity);
tblGroupModel.setValue(TBL_DATA_NAME_GROUP, name);
tblGroupModel.setValue(TBL_DATA_UNIVERSALNAME_GROUP, universalId);
tblGroupModel.setValue(TBL_DATA_ACTION_HREF_GROUP, stringToHex(universalId));
if (combinedType) {
try {
tblGroupModel.setValue(TBL_DATA_TYPE_GROUP, model.getLocalizedString("agenttype." + model.getAgentType(entity)));
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
}
}
cacheAgentGroups.add(universalId);
}
mapCache.put(CACHE_AGENT_GROUPS, cacheAgentGroups);
}
szCache.setValue((Serializable) mapCache);
} else {
szCache.setValue(null);
}
}
use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class AgentsViewBean method beginDisplay.
/**
* Sets the agent title and populates the agent and agent group
* action table.
*
* @param event Display Event.
* @throws ModelControlException if cannot access to framework model.
*/
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event, false);
resetButtonState(TBL_BUTTON_DELETE);
AgentsModel model = (AgentsModel) getModel();
String agentType = getDisplayIDType();
Object[] param = { agentType };
ptModel.setPageTitleText(model.getLocalizedString("agenttype." + agentType));
ptModel.setPageTitleHelpMessage(model.getLocalizedString("agenttype." + agentType + ".help"));
tblModel.setTitle(MessageFormat.format(model.getLocalizedString("table.agents.title.name"), param));
tblModel.setTitleLabel(MessageFormat.format(model.getLocalizedString("table.agents.summary"), param));
tblModel.setSummary(MessageFormat.format(model.getLocalizedString("table.agents.summary"), param));
tblGroupModel.setTitle(MessageFormat.format(model.getLocalizedString("table.agent.groups.title.name"), param));
tblGroupModel.setTitleLabel(MessageFormat.format(model.getLocalizedString("table.agent.groups.summary"), param));
tblGroupModel.setSummary(MessageFormat.format(model.getLocalizedString("table.agent.groups.summary"), param));
getAgentNames();
CCButton b = (CCButton) getChild(TBL_BUTTON_DELETE);
b.setDisabled(true);
b = (CCButton) getChild(TBL_BUTTON_DELETE_GROUP);
b.setDisabled(true);
}
use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class GenericAgentProfileViewBean method createTabModel.
protected void createTabModel() {
String agentType = getAgentType();
if (isLocalConfig(agentType)) {
agentType = AgentsViewBean.AGENT_2_2;
}
if (agentType != null) {
super.createTabModel();
AgentsModel model = (AgentsModel) getModel();
AgentTabManager mgr = AgentTabManager.getInstance();
List tabs = mgr.getTabs(agentType);
if ((tabs != null) && !tabs.isEmpty()) {
for (int i = 0; i < tabs.size(); i++) {
String tabName = (String) tabs.get(i);
tabModel.addNode(new CCNavNode(Integer.parseInt(TAB_PREFIX + i), model.getLocalizedString("tab.label." + agentType + "." + tabName), "", ""));
}
} else {
tabModel.addNode(new CCNavNode(TAB_GENERAL_ID, "tab.general", "", ""));
}
String group = (String) getPageSessionAttribute(IS_GROUP);
if ((group != null) && group.equals("true")) {
tabModel.addNode(new CCNavNode(TAB_GROUP_ID, "tab.group", "", ""));
}
}
}
use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.
the class AgentGroupMembersViewBean method beginDisplay.
/**
* Displays servers and sites information.
*
* @param event Display Event.
* @throws ModelControlException if unable to initialize model.
*/
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
AgentsModel model = (AgentsModel) getModel();
String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
try {
Set agents = model.getAgentGroupMembers(universalId);
if ((agents == null) || agents.isEmpty()) {
setDisplayFieldValue(CHILD_MEMBERS, model.getLocalizedString("agentconfig.group.members.nomembers"));
} else {
Set ordered = new TreeSet();
Map nameToId = new HashMap(agents.size() * 2);
for (Iterator i = agents.iterator(); i.hasNext(); ) {
AMIdentity amid = (AMIdentity) i.next();
String name = amid.getName();
ordered.add(name);
nameToId.put(name, amid.getUniversalId());
}
StringBuilder buff = new StringBuilder();
for (Iterator i = ordered.iterator(); i.hasNext(); ) {
String name = (String) i.next();
buff.append(name).append(" (").append((String) nameToId.get(name)).append(")<br />");
}
setDisplayFieldValue(CHILD_MEMBERS, buff.toString());
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
Aggregations