use of com.sun.identity.console.realm.model.ServicesModel in project OpenAM by OpenRock.
the class ServicesSelectViewBean method handleButton2Request.
/**
* Handles next button request.
*
* @param event Request invocation event.
*/
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
ServicesModel model = (ServicesModel) getModel();
String serviceName = (String) getDisplayFieldValue(ATTR_SERVICE_LIST);
serviceName = serviceName.trim();
if (serviceName.length() > 0) {
SCUtils utils = new SCUtils(serviceName, model);
String propertiesViewBeanURL = utils.getServiceDisplayURL();
if ((propertiesViewBeanURL != null) && (propertiesViewBeanURL.trim().length() > 0)) {
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
if (curRealm == null) {
curRealm = AMModelBase.getStartDN(getRequestContext().getRequest());
}
try {
String pageTrailID = (String) getPageSessionAttribute(PG_SESSION_PAGE_TRAIL_ID);
propertiesViewBeanURL += "?ServiceName=" + serviceName + "&Location=" + stringToHex(curRealm) + "&Template=true&Op=" + AMAdminConstants.OPERATION_ADD + "&" + PG_SESSION_PAGE_TRAIL_ID + "=" + pageTrailID;
HttpServletResponse response = getRequestContext().getResponse();
backTrail();
response.sendRedirect(propertiesViewBeanURL);
} catch (UnsupportedEncodingException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
} catch (IOException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
} else {
ServicesAddViewBean vb = (ServicesAddViewBean) getViewBean(ServicesAddViewBean.class);
setPageSessionAttribute(ServicesAddViewBean.SERVICE_NAME, serviceName);
unlockPageTrailForSwapping();
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
}
} else {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "services.missing.servicename");
forwardTo();
}
}
use of com.sun.identity.console.realm.model.ServicesModel in project OpenAM by OpenRock.
the class ServicesViewBean method getServiceNames.
private void getServiceNames() {
ServicesModel model = (ServicesModel) getModel();
try {
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
populateTableModel(model.getAssignedServiceNames(curRealm));
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
use of com.sun.identity.console.realm.model.ServicesModel in project OpenAM by OpenRock.
the class ServicesViewBean method beginDisplay.
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
resetButtonState(TBL_BUTTON_DELETE);
getServiceNames();
setPageTitle(getModel(), "page.title.realms.services");
ServicesModel model = (ServicesModel) getModel();
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
try {
if (model.getAssignableServiceNames(curRealm).isEmpty()) {
CCButton btnAdd = (CCButton) getChild(TBL_BUTTON_ADD);
btnAdd.setDisabled(true);
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "services.noservices.for.assignment.message");
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
CCButton btnAdd = (CCButton) getChild(TBL_BUTTON_ADD);
btnAdd.setDisabled(true);
}
}
use of com.sun.identity.console.realm.model.ServicesModel in project OpenAM by OpenRock.
the class ServicesViewBean method populateTableModel.
private void populateTableModel(Map nameToDisplayNames) {
tblModel.clearAll();
SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
if ((nameToDisplayNames != null) && !nameToDisplayNames.isEmpty()) {
Map reverseMap = AMFormatUtils.reverseStringMap(nameToDisplayNames);
ServicesModel model = (ServicesModel) getModel();
List list = AMFormatUtils.sortKeyInMap(reverseMap, model.getUserLocale());
boolean firstEntry = true;
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
if (firstEntry) {
firstEntry = false;
} else {
tblModel.appendRow();
}
String displayName = (String) iter.next();
String name = (String) reverseMap.get(displayName);
tblModel.setValue(TF_DATA_NAME, name);
tblModel.setValue(TBL_DATA_NAME, displayName);
tblModel.setValue(TBL_DATA_ACTION_HREF, name);
tblModel.setValue(TBL_DATA_ACTION_LABEL, "table.services.action.edit");
}
szCache.setValue((Serializable) nameToDisplayNames);
} else {
szCache.setValue(null);
}
}
use of com.sun.identity.console.realm.model.ServicesModel in project OpenAM by OpenRock.
the class ServicesViewBean method handleTblButtonDeleteRequest.
/**
* Deletes ID Repo.
*
* @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);
for (int i = 0; i < selected.length; i++) {
tblModel.setRowIndex(selected[i].intValue());
names.add((String) tblModel.getValue(TF_DATA_NAME));
}
try {
ServicesModel model = (ServicesModel) getModel();
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
model.unassignServices(curRealm, names);
if (selected.length == 1) {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "services.message.deleted");
} else {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "services.message.deleted.pural");
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
Aggregations