use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.
the class RMRealmViewBean method handleTblDataActionHrefRequest.
/**
* Handles edit realm request.
*
* @param event Request Invocation Event.
* @throws ModelControlException if table model cannot be restored.
*/
public void handleTblDataActionHrefRequest(RequestInvocationEvent event) throws ModelControlException {
// store the current realm name and the current selected tab
// in the page session. Need to do this so after returning
// from profile object we get placed in the correct location.
String prevRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
setPageSessionAttribute(AMAdminConstants.PREVIOUS_REALM, prevRealm);
String newRealm = hexToString((String) getDisplayFieldValue(TBL_DATA_ACTION_HREF));
setPageSessionAttribute(AMAdminConstants.CURRENT_REALM, newRealm);
setCurrentLocation(newRealm);
// store the current selected tab in the page session
String tmp = (String) getPageSessionAttribute(getTrackingTabIDName());
setPageSessionAttribute(AMAdminConstants.PREVIOUS_TAB_ID, tmp);
AMViewConfig config = AMViewConfig.getInstance();
RMRealmModel model = (RMRealmModel) getModel();
unlockPageTrail();
try {
AMViewBeanBase vb = config.getTabViewBean(this, newRealm, model, "realms", -1, -1);
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
} catch (AMConsoleException e) {
setPageSessionAttribute(AMAdminConstants.CURRENT_REALM, prevRealm);
removePageSessionAttribute(AMAdminConstants.PREVIOUS_TAB_ID);
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
}
use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.
the class RMRealmViewBean method handleTblButtonDeleteRequest.
/**
* Deletes realms.
*
* @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();
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
Integer[] selected = tblModel.getSelectedRows();
SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
List list = (List) szCache.getSerializedObj();
Set names = new HashSet(selected.length * 2);
for (int i = 0; i < selected.length; i++) {
String name = (String) list.get(selected[i].intValue());
/*
* make sure the realm name starts with / to give it a
* fully qualified look. This value will be set in the log file
*/
if (!name.startsWith("/")) {
name = "/" + name;
}
names.add(name);
}
try {
RMRealmModel model = (RMRealmModel) getModel();
model.deleteSubRealms(curRealm, names);
if (selected.length == 1) {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "realm.message.deleted");
} else {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "realm.message.deleted.pural");
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.
the class RMRealmViewBean method populateTableModel.
private void populateTableModel(Collection realmNames) {
tblModel.clearAll();
SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
RMRealmModel model = (RMRealmModel) getModel();
tblModel.setMaxRows(model.getPageSize());
if ((realmNames != null) && !realmNames.isEmpty()) {
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
List cache = new ArrayList(realmNames.size());
boolean firstEntry = true;
String startDN = model.getStartDN();
int counter = 0;
for (Iterator iter = realmNames.iterator(); iter.hasNext(); counter++) {
if (firstEntry) {
firstEntry = false;
} else {
tblModel.appendRow();
}
String name = (String) iter.next();
String fqName = null;
String displayName = null;
if (name.equals(startDN)) {
tblModel.setSelectionVisible(counter, false);
fqName = name;
displayName = AMFormatUtils.DNToName(model, model.getStartDSDN());
} else {
int idx = name.lastIndexOf('/');
displayName = (idx == -1) ? name : name.substring(idx + 1);
tblModel.setSelectionVisible(counter, true);
fqName = name;
}
/*
* Set name column info. Need to unescape the value as it
* may contain a '/' character.
*/
tblModel.setValue(TBL_DATA_ACTION_HREF, stringToHex(fqName));
tblModel.setValue(TBL_DATA_NAME, SMSSchema.unescapeName(displayName));
// set location column info
tblModel.setValue(TBL_DATA_PATH, getPath(name));
cache.add(name);
}
szCache.setValue((ArrayList) cache);
} else {
szCache.setValue(null);
}
}
use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.
the class RMRealmAddViewBean method handleButton1Request.
/**
* Handles create realm request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
RMRealmModel model = (RMRealmModel) getModel();
AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
String realmName = (String) getDisplayFieldValue(RMRealmModel.TF_NAME);
realmName = realmName.trim();
String parent = (String) getDisplayFieldValue(RMRealmModel.TF_PARENT);
if (parent != null) {
parent = parent.trim();
} else {
parent = model.getStartDN();
}
if (realmName.length() > 0) {
try {
Map values = ps.getAttributeValues(model.getDataMap(), false, model);
model.createSubRealm(parent, realmName, values);
backTrail();
RMRealmViewBean vb = (RMRealmViewBean) getViewBean(RMRealmViewBean.class);
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
} else {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "realm.missing.realmName");
forwardTo();
}
}
use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.
the class RMRealmAddViewBean method setDefaultValues.
private void setDefaultValues() {
RMRealmModel model = (RMRealmModel) getModel();
Map defaultValues = model.getDefaultValues();
AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
ps.setAttributeValues(defaultValues, model);
}
Aggregations