use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.
the class EntityEditViewBean method createPropertyModel.
protected boolean createPropertyModel() {
boolean created = super.createPropertyModel();
if (created) {
String type = (String) getPageSessionAttribute(ENTITY_TYPE);
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
EntitiesModel model = (EntitiesModel) getModel();
tabModel = new CCTabsModel();
tabModel.addNode(new CCNavNode(TAB_PROFILE, "profile.tab", "", ""));
if (model.canAssignService(curRealm, type)) {
tabModel.addNode(new CCNavNode(TAB_SERVICES, "services.tab", "", ""));
}
try {
Set memberOfs = model.getIdTypeMemberOf(curRealm, type);
for (Iterator iter = memberOfs.iterator(); iter.hasNext(); ) {
IdType t = (IdType) iter.next();
tabModel.addNode(new CCNavNode(t.hashCode(), t.getName(), "", ""));
}
Set beMemberOfs = model.getIdTypeBeMemberOf(curRealm, type);
if ((beMemberOfs != null) && !beMemberOfs.isEmpty()) {
for (Iterator i = beMemberOfs.iterator(); i.hasNext(); ) {
IdType t = (IdType) i.next();
tabModel.addNode(new CCNavNode(t.hashCode(), t.getName(), "", ""));
}
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
tabModel.setSelectedNode(TAB_PROFILE);
}
return created;
}
use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.
the class EntityAddViewBean method setDefaultValues.
protected void setDefaultValues(String type) throws AMConsoleException {
if (!submitCycle && (propertySheetModel != null)) {
EntitiesModel model = (EntitiesModel) getModel();
// null for agent type
Map defaultValues = model.getDefaultAttributeValues(type, null, true);
for (Iterator i = defaultValues.keySet().iterator(); i.hasNext(); ) {
String name = (String) i.next();
Set values = (Set) defaultValues.get(name);
if ((values != null) && !values.isEmpty()) {
propertySheetModel.setValues(name, values.toArray(), model);
}
}
}
}
use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.
the class EntityMembersViewBean method getAssignableMembers.
private OptionList getAssignableMembers() {
OptionList avail = null;
EntitiesModel model = (EntitiesModel) getModel();
if ((filter == null) || (filter.trim().length() == 0)) {
filter = "*";
setDisplayFieldValue(TF_FILTER, "*");
}
setDisplayFieldValue(TF_FILTER, filter);
try {
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String searchType = (String) getPageSessionAttribute(EntityMembersViewBean.PG_SESSION_MEMBER_TYPE);
IdSearchResults results = model.getEntityNames(curRealm, searchType, filter);
int errorCode = results.getErrorCode();
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;
}
// assignable will contain users which shouldn't be displayed in
// the console (dsameuser, etc...)
Set assignable = results.getSearchResults();
assignable.removeAll(model.getSpecialUsers(curRealm));
String universalId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
removeAlreadyAssignedMembers(assignable);
avail = getOptionListForEntities(assignable);
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
return avail;
}
use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.
the class EntityMembershipViewBean method handleButton1Request.
public void handleButton1Request(RequestInvocationEvent event) {
submitCycle = true;
CCAddRemove child = (CCAddRemove) getChild(ADD_REMOVE_MEMBERS);
child.restoreStateData();
CCAddRemoveModel addRemoveModel = (CCAddRemoveModel) propertySheetModel.getModel(ADD_REMOVE_MEMBERS);
OptionList os = addRemoveModel.getSelectedOptionList();
EntitiesModel model = (EntitiesModel) getModel();
String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String type = (String) getPageSessionAttribute(PG_SESSION_MEMBER_TYPE);
try {
Set entities = getEntitiesID(model.getMembership(curRealm, universalId, type));
Set selected = getValues(os);
Set toAdd = new HashSet(selected);
toAdd.removeAll(entities);
entities.removeAll(selected);
if (!toAdd.isEmpty()) {
model.addMemberships(universalId, toAdd);
}
if (!entities.isEmpty()) {
model.removeMemberships(universalId, entities);
}
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.
the class EntityMembershipViewBean method getAssignableMembership.
private OptionList getAssignableMembership() {
OptionList avail = null;
EntitiesModel model = (EntitiesModel) getModel();
if ((filter == null) || (filter.trim().length() == 0)) {
filter = "*";
setDisplayFieldValue(TF_FILTER, "*");
}
setDisplayFieldValue(TF_FILTER, filter);
try {
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String searchType = (String) getPageSessionAttribute(EntityMembersViewBean.PG_SESSION_MEMBER_TYPE);
IdSearchResults results = model.getEntityNames(curRealm, searchType, filter);
int errorCode = results.getErrorCode();
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 members = results.getSearchResults();
String universalId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
removeAlreadyAssignedMembers(members);
avail = getOptionListForEntities(members);
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
return avail;
}
Aggregations