use of org.springframework.web.portlet.bind.annotation.ActionMapping 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.springframework.web.portlet.bind.annotation.ActionMapping in project uPortal by Jasig.
the class DirectoryPortletController method submitSearch.
@ActionMapping
public void submitSearch(ActionRequest request, ActionResponse response, @RequestParam(value = "query", required = false) String query) {
// Should we request to maximize?
PortletPreferences prefs = request.getPreferences();
boolean maximize = Boolean.parseBoolean(// default is true
prefs.getValue(MAXIMIZE_ON_SEARCH_PREFERENCE, "true"));
if (maximize) {
try {
response.setWindowState(WindowState.MAXIMIZED);
} catch (WindowStateException e) {
log.warn("Failed to set the window state to MAXIMIZED", e);
}
}
// Forward the query parameter...
if (query != null) {
response.setRenderParameter("query", query);
}
}
use of org.springframework.web.portlet.bind.annotation.ActionMapping in project uPortal by Jasig.
the class FavoritesEditController method unFavoriteNode.
/**
* Un-favorite a favorite node (portlet or collection) identified by node ID. Routed by the
* action=delete parameter. If no favorites remain after un-favoriting, switches portlet mode to
* VIEW.
*
* <p>Sets render parameters: successMessageCode: message code of success message if applicable
* errorMessageCode: message code of error message if applicable nameOfFavoriteActedUpon:
* user-facing name of favorite acted upon. action: will be set to "list" to facilitate not
* repeatedly attempting delete.
*
* <p>Exactly one of [successMessageCode|errorMessageCode] render parameters will be set.
* nameOfFavoriteActedUpon and action will always be set.
*
* @param nodeId identifier of target node
* @param response ActionResponse onto which render parameters will, mode may, be set
*/
@ActionMapping(params = { "action=delete" })
public void unFavoriteNode(@RequestParam("nodeId") String nodeId, ActionResponse response) {
try {
// ferret out the layout manager
HttpServletRequest servletRequest = this.portalRequestUtils.getCurrentPortalRequest();
IUserInstance userInstance = this.userInstanceManager.getUserInstance(servletRequest);
IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
IUserLayoutManager layoutManager = preferencesManager.getUserLayoutManager();
IUserLayoutNodeDescription nodeDescription = layoutManager.getNode(nodeId);
String userFacingNodeName = nodeDescription.getName();
response.setRenderParameter("nameOfFavoriteActedUpon", userFacingNodeName);
if (nodeDescription.isDeleteAllowed()) {
boolean nodeSuccessfullyDeleted = layoutManager.deleteNode(nodeId);
if (nodeSuccessfullyDeleted) {
layoutManager.saveUserLayout();
response.setRenderParameter("successMessageCode", "favorites.unfavorite.success.parameterized");
IUserLayout updatedLayout = layoutManager.getUserLayout();
// if removed last favorite, return to VIEW mode
if (!FavoritesUtils.hasAnyFavorites(updatedLayout)) {
response.setPortletMode(PortletMode.VIEW);
}
logger.debug("Successfully unfavorited [{}]", nodeDescription);
} else {
logger.error("Failed to delete node [{}] on unfavorite request, but this should have succeeded?", nodeDescription);
response.setRenderParameter("errorMessageCode", "favorites.unfavorite.fail.parameterized");
}
} else {
logger.warn("Attempt to unfavorite [{}] failed because user lacks permission to delete that layout node.", nodeDescription);
response.setRenderParameter("errorMessageCode", "favorites.unfavorite.fail.lack.permission.parameterized");
}
} catch (Exception e) {
// TODO: this log message is kind of useless without the username to put the node in context
logger.error("Something went wrong unfavoriting nodeId [{}].", nodeId);
// may have failed to load node description, so fall back on describing by id
final String fallbackUserFacingNodeName = "node with id " + nodeId;
response.setRenderParameter("errorMessageCode", "favorites.unfavorite.fail.parameterized");
response.setRenderParameter("nameOfFavoriteActedUpon", fallbackUserFacingNodeName);
}
response.setRenderParameter("action", "list");
}
use of org.springframework.web.portlet.bind.annotation.ActionMapping 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.springframework.web.portlet.bind.annotation.ActionMapping 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