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));
}
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);
}
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);
}
Aggregations