Search in sources :

Example 1 with TenantOperationResponse

use of org.apereo.portal.tenants.TenantOperationResponse in project uPortal by Jasig.

the class TenantManagerController method doListenerAction.

/** @since 4.3 */
@ActionMapping(params = "action=doListenerAction")
public void doListenerAction(ActionRequest req, ActionResponse res, @RequestParam("fname") String fname, final PortletSession session) {
    final ITenantManagementAction action = tenantService.getAction(fname);
    final ITenant tenant = (ITenant) session.getAttribute(CURRENT_TENANT_SESSION_ATTRIBUTE);
    if (tenant == null) {
        throw new IllegalStateException("No current tenant");
    }
    TenantOperationResponse response = action.invoke(tenant);
    forwardToReportScreen(req, res, action.getMessageCode(), Collections.singletonList(response));
}
Also used : ITenant(org.apereo.portal.tenants.ITenant) TenantOperationResponse(org.apereo.portal.tenants.TenantOperationResponse) ITenantManagementAction(org.apereo.portal.tenants.ITenantManagementAction) ActionMapping(org.springframework.web.portlet.bind.annotation.ActionMapping)

Example 2 with TenantOperationResponse

use of org.apereo.portal.tenants.TenantOperationResponse 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)

Example 3 with TenantOperationResponse

use of org.apereo.portal.tenants.TenantOperationResponse in project uPortal by Jasig.

the class TenantManagerController method doUpdateTenant.

@ActionMapping(params = "action=doUpdateTenant")
public void doUpdateTenant(final ActionRequest req, final ActionResponse res, final PortletSession session) {
    final ITenant tenant = (ITenant) session.getAttribute(CURRENT_TENANT_SESSION_ATTRIBUTE);
    if (tenant == null) {
        throw new IllegalStateException("No current tenant");
    }
    final Map<String, String> attributes = gatherAttributesFromPortletRequest(req);
    // Validation
    final Set<String> invalidFields = detectInvalidFields(tenant.getName(), tenant.getFname(), attributes);
    if (!invalidFields.isEmpty()) {
        /*
             * Something wasn't valid;  return the user to the addTenant screen.
             */
        this.returnToInvalidForm(req, res, tenant.getName(), attributes, invalidFields, "showTenantDetails");
        return;
    }
    final List<TenantOperationResponse> responses = new ArrayList<>();
    tenantService.updateTenant(tenant, attributes, responses);
    forwardToReportScreen(req, res, "tenant.manager.update.attributes", responses);
}
Also used : ITenant(org.apereo.portal.tenants.ITenant) TenantOperationResponse(org.apereo.portal.tenants.TenantOperationResponse) ArrayList(java.util.ArrayList) ActionMapping(org.springframework.web.portlet.bind.annotation.ActionMapping)

Aggregations

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