use of org.apereo.portal.tenants.ITenantOperationsListener in project uPortal by Jasig.
the class TenantManagerController method doAddTenant.
@ActionMapping(params = "action=doAddTenant")
public void doAddTenant(ActionRequest req, ActionResponse res, final PortletSession session, @RequestParam("name") String name) {
final Map<String, String> attributes = gatherAttributesFromPortletRequest(req);
final String fname = calculateFnameFromName(name);
// Validation
final Set<String> invalidFields = detectInvalidFields(name, fname, attributes);
if (!invalidFields.isEmpty()) {
/*
* Something wasn't valid; return the user to the addTenant screen.
*/
this.returnToInvalidForm(req, res, name, attributes, invalidFields, "showAddTenant");
return;
}
// Honor the user's choices as far as optional listeners
final List<String> selectedListenerFnames = (req.getParameterValues(OPTIONAL_LISTENER_PARAMETER) != null) ? Arrays.asList(req.getParameterValues(OPTIONAL_LISTENER_PARAMETER)) : // None were selected
new ArrayList<String>(0);
final Set<String> skipListenerFnames = new HashSet<>();
for (ITenantOperationsListener listener : tenantService.getOptionalOperationsListeners()) {
if (!selectedListenerFnames.contains(listener.getFname())) {
skipListenerFnames.add(listener.getFname());
}
}
final List<TenantOperationResponse> responses = new ArrayList<>();
tenantService.createTenant(name, fname, attributes, skipListenerFnames, responses);
forwardToReportScreen(req, res, "tenant.manager.add", responses);
}
Aggregations