new PropertyModel<List<ConnectorCapability>>(this, "selectedCapabilities"), capabilities);
connectorForm.add(capabilitiesPalette);
// form - submit / cancel buttons
final AjaxButton submit = new IndicatingAjaxButton("apply", new Model<String>(getString("submit"))) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
final ConnInstanceTO conn = (ConnInstanceTO) form.getModelObject();
conn.setConnectorName(bundleTO.getConnectorName());
conn.setBundleName(bundleTO.getBundleName());
conn.setVersion(bundleTO.getVersion());
conn.setConfiguration(new HashSet<ConnConfProperty>(connPropView.getModelObject()));
// Set the model object's capabilites to capabilitiesPalette's converted Set
conn.setCapabilities(selectedCapabilities.isEmpty()
? EnumSet.noneOf(ConnectorCapability.class)
: EnumSet.copyOf(selectedCapabilities));
try {
if (connInstanceTO.getId() == 0) {
restClient.create(conn);
} else {
restClient.update(conn);
}
((Resources) pageRef.getPage()).setModalResult(true);
window.close(target);
} catch (SyncopeClientCompositeErrorException e) {
error(getString("error") + ":" + e.getMessage());
target.add(feedbackPanel);
((Resources) pageRef.getPage()).setModalResult(false);
LOG.error("While creating or updating connector {}", conn, e);
}
}
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
target.add(feedbackPanel);
}
};
String roles = connInstanceTO.getId() == 0
? xmlRolesReader.getAllAllowedRoles("Connectors", "create")
: xmlRolesReader.getAllAllowedRoles("Connectors", "update");
MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, roles);
connectorForm.add(submit);
final IndicatingAjaxButton cancel = new IndicatingAjaxButton("cancel", new ResourceModel("cancel")) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
window.close(target);
}
};
cancel.setDefaultFormProcessing(false);
connectorForm.add(cancel);
}