use of com.sun.identity.console.federation.model.ImportEntityModel in project OpenAM by OpenRock.
the class ImportEntityViewBean method handleButton1Request.
/**
* Handles upload entity button request. There are two fields on this page:
* one for standard metadata and the other for extended. The standard is
* required.
*
* @param event Request invocation event
* @throws ModelControlException
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
ImportEntityModel model = (ImportEntityModel) getModel();
Map data = new HashMap(6);
String realm = (String) getDisplayFieldValue(model.REALM_NAME);
data.put(model.REALM_NAME, realm);
String radioMeta = (String) getDisplayFieldValue("radioMeta");
String meta = (radioMeta.equals("url")) ? (String) getDisplayFieldValue("tfMetadataFileURL") : (String) getDisplayFieldValue("tfMetadataFile");
String radioExtended = (String) getDisplayFieldValue("radioExtended");
String extended = (radioExtended.equals("url")) ? (String) getDisplayFieldValue("tfExtendeddataFileURL") : (String) getDisplayFieldValue("tfExtendeddataFile");
if ((meta == null) || (meta.length() == 0)) {
psModel.setErrorProperty("standardFileNameProperty", true);
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.input.error", "import.entity.missing.metadata");
forwardTo();
} else {
data.put(ImportEntityModel.STANDARD_META, meta);
if ((extended != null) || (extended.trim().length() > 0)) {
data.put(ImportEntityModel.EXTENDED_META, extended);
}
try {
model.importEntity(data);
StringBuilder buff = new StringBuilder();
// build the success message.
// don't need the realm name in the message so remove it first.
data.remove(ImportEntityModel.REALM_NAME);
for (Iterator i = data.keySet().iterator(); i.hasNext(); ) {
String key = (String) i.next();
String value = (String) data.get(key);
if ((value != null) && (value.length() > 0)) {
String val = (String) data.get(key);
if (val.startsWith("http")) {
if (buff.length() > 0) {
buff.append(", ");
}
buff.append(val);
} else {
int idx = val.lastIndexOf("<!-- ");
if (idx != -1) {
int idx1 = val.lastIndexOf(" -->");
if (idx1 != -1) {
val = val.substring(idx + 5, idx1);
}
}
if (buff.length() > 0) {
buff.append(", ");
}
buff.append(val);
}
}
}
String message = "";
if (buff.length() > 0) {
Object[] params = { buff.toString() };
message = MessageFormat.format(model.getLocalizedString("import.entity.metadata.success"), params);
}
// set the message in the main view
setPageSessionAttribute(FederationViewBean.MESSAGE_TEXT, message);
FederationViewBean vb = (FederationViewBean) getViewBean(FederationViewBean.class);
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
} catch (AMConsoleException ame) {
debug.warning("ImportEntityViewBean.handleButton1req ", ame);
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", ame.getMessage());
forwardTo();
}
}
}
use of com.sun.identity.console.federation.model.ImportEntityModel in project OpenAM by OpenRock.
the class ImportEntityViewBean method populateRealmData.
private void populateRealmData() {
Set realmNames = Collections.EMPTY_SET;
ImportEntityModel model = (ImportEntityModel) getModel();
try {
realmNames = model.getRealmNames("/", "*");
CCDropDownMenu menu = (CCDropDownMenu) getChild(ImportEntityModel.REALM_NAME);
OptionList sortedList = createOptionList(realmNames);
OptionList optList = new OptionList();
int size = sortedList.size();
for (int i = 0; i < size; i++) {
String name = sortedList.getValue(i);
optList.add(getPath(name), name);
}
menu.setOptions(optList);
} catch (AMConsoleException e) {
debug.warning("ImportEntityViewBean.populateRealmData ", e);
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "import.entity.populaterealmdata.error");
}
}
Aggregations