ConfigureOAuth2ViewBean.java revision 8b6198b1170e3128c5df83267597f0058d07c70d
0N/Apackage com.sun.identity.console.task;
1472N/A
0N/Aimport java.text.MessageFormat;
0N/Aimport java.util.Set;
0N/A
0N/Aimport javax.servlet.http.HttpServletRequest;
0N/A
0N/Aimport com.iplanet.jato.view.View;
0N/Aimport com.iplanet.jato.view.event.ChildContentDisplayEvent;
0N/Aimport com.iplanet.jato.view.event.DisplayEvent;
0N/Aimport com.sun.identity.console.base.AMPrimaryMastHeadViewBean;
0N/Aimport com.sun.identity.console.base.AMPropertySheet;
0N/Aimport com.sun.identity.console.base.model.AMConsoleException;
0N/Aimport com.sun.identity.console.base.model.AMModel;
0N/Aimport com.sun.identity.console.base.model.AMPropertySheetModel;
0N/Aimport com.sun.identity.console.task.model.OAuth2Model;
0N/Aimport com.sun.identity.console.task.model.OAuth2ModelImpl;
0N/Aimport com.sun.identity.console.task.model.TaskModel;
1472N/Aimport com.sun.web.ui.model.CCActionTableModel;
1472N/Aimport com.sun.web.ui.model.CCPageTitleModel;
1472N/Aimport com.sun.web.ui.view.alert.CCAlert;
0N/Aimport com.sun.web.ui.view.html.CCDropDownMenu;
0N/Aimport com.sun.web.ui.view.pagetitle.CCPageTitle;
0N/A
0N/Apublic class ConfigureOAuth2ViewBean
0N/A extends AMPrimaryMastHeadViewBean
0N/A{
0N/A public static final String DEFAULT_DISPLAY_URL =
0N/A "/console/task/ConfigureOAuth2.jsp";
0N/A private static final String PAGETITLE = "pgtitle";
304N/A private static final String PROPERTY_ATTRIBUTE = "propertyAttributes";
304N/A private static final String REALM = "tfRealm";
304N/A private static final String TITLE_MESSAGE = "configure.oauth2profile.title.message";
private CCPageTitleModel ptModel;
private CCActionTableModel tableModel;
private AMPropertySheetModel propertySheetModel;
//public void forwardTo(RequestContext rc) {
//}
public ConfigureOAuth2ViewBean() {
super("ConfigureOAuth2");
setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
createPageTitleModel();
createPropertyModel();
registerChildren();
}
protected void registerChildren() {
//ptModel.registerChildren(this);
propertySheetModel.registerChildren(this);
registerChild(PAGETITLE, CCPageTitle.class);
super.registerChildren();
}
protected View createChild(String name) {
View view = null;
if (name.equals(PAGETITLE)) {
view = new CCPageTitle(this, ptModel, name);
} else if (ptModel.isChildSupported(name)) {
view = ptModel.createChild(this, name);
} else if (name.equals(PROPERTY_ATTRIBUTE)) {
view = new AMPropertySheet(this, propertySheetModel, name);
} else if (propertySheetModel.isChildSupported(name)) {
view = propertySheetModel.createChild(this, name, getModel());
} else {
view = super.createChild(name);
}
return view;
}
private void createPageTitleModel() {
ptModel = new CCPageTitleModel(
getClass().getClassLoader().getResourceAsStream(
"com/sun/identity/console/twoBtnsPageTitle.xml"));
ptModel.setValue("button1", "button.create");
ptModel.setValue("button2", "button.cancel");
}
private void createPropertyModel() {
propertySheetModel = new AMPropertySheetModel(
getClass().getClassLoader().getResourceAsStream(
"com/sun/identity/console/propertyConfigureOAuth2.xml"));
propertySheetModel.clear();
}
protected AMModel getModelInternal() {
HttpServletRequest req = getRequestContext().getRequest();
return new OAuth2ModelImpl(req, getPageSessionAttributes());
}
public void beginDisplay(DisplayEvent e) {
try {
OAuth2Model model = (OAuth2Model) getModel();
Set realms = model.getRealms();
CCDropDownMenu menuRealm = (CCDropDownMenu) getChild(REALM);
menuRealm.setOptions(createOptionList(realms));
String realm = getRequestContext().getRequest().getParameter("realm");
if (realm != null && !realm.trim().isEmpty()) {
setDisplayFieldValue(REALM, realm);
}
final String titleMessage = model.getLocalizedString(TITLE_MESSAGE);
ptModel.setPageTitleText(MessageFormat.format(titleMessage, model.getDisplayName()));
ptModel.setPageTitleHelpMessage(model.getLocalizedHelpMessage());
} catch (AMConsoleException ex) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error",
ex.getMessage());
}
}
public String endPropertyAttributesDisplay(
ChildContentDisplayEvent event
) {
String html = event.getContent();
return html;
}
static String removeSortHref(String html) {
return html;
}
}