use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.
the class EntityMembersViewBean 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.getMembers(curRealm, universalId, type));
Set selected = getValues(os);
Set toAdd = new HashSet(selected);
toAdd.removeAll(entities);
entities.removeAll(selected);
if (!toAdd.isEmpty()) {
model.addMembers(universalId, toAdd);
}
if (!entities.isEmpty()) {
model.removeMembers(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 EntitiesViewBean method populateTableModel.
private void populateTableModel(Collection entityNames) {
tblModel.clearAll();
SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
if ((entityNames != null) && !entityNames.isEmpty()) {
// set the paging size
EntitiesModel model = (EntitiesModel) getModel();
tblModel.setMaxRows(model.getPageSize());
// remove the special users from the set of enitities to display
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
Set specialUsers = model.getSpecialUsers(curRealm);
entityNames.removeAll(specialUsers);
// get the current logged in user
AMIdentity curUser = null;
try {
curUser = IdUtils.getIdentity(model.getUserSSOToken(), model.getUniversalID());
} catch (IdRepoException idr) {
// do nothing
}
int counter = 0;
boolean firstEntry = true;
List cache = new ArrayList(entityNames.size());
for (Iterator iter = entityNames.iterator(); iter.hasNext(); ) {
AMIdentity entity = (AMIdentity) iter.next();
if (firstEntry) {
firstEntry = false;
} else {
tblModel.appendRow();
}
String name = AMFormatUtils.getIdentityDisplayName(model, entity);
// hide the checkbox if this is the current user or amadmin
boolean showCheckbox = ((curUser != null) && (!curUser.equals(entity))) && !model.isAmadminUser(entity);
tblModel.setSelectionVisible(counter++, showCheckbox);
String universalId = IdUtils.getUniversalId(entity);
tblModel.setValue(TBL_DATA_NAME, name);
tblModel.setValue(TBL_DATA_ID, LDAPUtils.rdnValueFromDn(universalId));
tblModel.setValue(TBL_DATA_UNIVERSALNAME, universalId);
tblModel.setValue(TBL_DATA_ACTION_HREF, stringToHex(universalId));
cache.add(universalId);
}
szCache.setValue((Serializable) cache);
} else {
szCache.setValue(null);
}
}
use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.
the class EntitiesViewBean method handleTblDataActionHrefRequest.
/**
* Forwards request to edit policy view bean.
*
* @param event Request Invocation Event.
*/
public void handleTblDataActionHrefRequest(RequestInvocationEvent event) {
EntitiesModel model = (EntitiesModel) getModel();
String universalId = hexToString((String) getDisplayFieldValue(TBL_DATA_ACTION_HREF));
setPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID, universalId);
try {
AMIdentity amid = IdUtils.getIdentity(model.getUserSSOToken(), universalId);
String idType = amid.getType().getName();
AMViewBeanBase vb = (AMViewBeanBase) getViewBean(EntityEditViewBean.class);
setPageSessionAttribute(EntityOpViewBeanBase.ENTITY_NAME, amid.getName());
setPageSessionAttribute(EntityOpViewBeanBase.ENTITY_TYPE, idType);
unlockPageTrail();
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
} catch (IdRepoException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
forwardTo();
}
}
use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.
the class EntitiesViewBean method getEntityNames.
private void getEntityNames() {
EntitiesModel model = (EntitiesModel) getModel();
String filter = ((String) getDisplayFieldValue(TF_FILTER));
if ((filter == null) || (filter.length() == 0)) {
filter = "*";
setDisplayFieldValue(TF_FILTER, "*");
} else {
filter = filter.trim();
}
try {
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
IdSearchResults results = model.getEntityNames(curRealm, getDisplayIDType(), 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;
}
populateTableModel(results.getSearchResults());
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
// disable the add button if there was an error
CCButton b = (CCButton) getChild(TBL_BUTTON_ADD);
b.setDisabled(true);
}
}
use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.
the class EntityEditViewBean method getIdType.
protected IdType getIdType(int hashCode) {
IdType idType = null;
EntitiesModel model = (EntitiesModel) getModel();
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
Map types = model.getSupportedEntityTypes(curRealm);
for (Iterator iter = types.keySet().iterator(); iter.hasNext() && (idType == null); ) {
try {
IdType type = IdUtils.getType((String) iter.next());
if (type.hashCode() == hashCode) {
idType = type;
}
} catch (IdRepoException e) {
// display message
}
}
return idType;
}
Aggregations