Search in sources :

Example 1 with ITenantOperationsListener

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);
}
Also used : TenantOperationResponse(org.apereo.portal.tenants.TenantOperationResponse) ArrayList(java.util.ArrayList) ITenantOperationsListener(org.apereo.portal.tenants.ITenantOperationsListener) HashSet(java.util.HashSet) ActionMapping(org.springframework.web.portlet.bind.annotation.ActionMapping)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ITenantOperationsListener (org.apereo.portal.tenants.ITenantOperationsListener)1 TenantOperationResponse (org.apereo.portal.tenants.TenantOperationResponse)1 ActionMapping (org.springframework.web.portlet.bind.annotation.ActionMapping)1