/** * Method to save the send settings. * * @param request The current request. * @param notificationSettings The settings to save. * @param result The result to bind errors and so on to. * @return The ModelAndView to use. */ @RequestMapping(method = RequestMethod.POST) public ModelAndView saveSettings( HttpServletRequest request, @ModelAttribute("command") ClientProfileNotificationsForm notificationSettings, BindingResult result) { Map<ClientConfigurationPropertyConstant, String> settings = new HashMap<ClientConfigurationPropertyConstant, String>(); settings.put( ClientProperty.NOTIFICATION_RENDER_ATTACHMENTLINKS, Boolean.toString(notificationSettings.isRenderAttachmentLinks())); settings.put( ClientProperty.NOTIFICATION_RENDER_PERMALINKS, Boolean.toString(notificationSettings.isRenderPermalinks())); settings.put( ClientProperty.INVITATION_RENDER_BLOG_PERMALINK, Boolean.toString(notificationSettings.isRenderBlogPermalinkInInvitation())); settings.put( ClientProperty.MAX_NUMBER_OF_MENTIONED_USERS, Integer.toString(notificationSettings.getMaxUsersToMention())); CommunoteRuntime.getInstance() .getConfigurationManager() .updateClientConfigurationProperties(settings); MessageHelper.saveMessageFromKey(request, "client.profile.notifications.success"); return get(); }
/** * Implementation of the exception resolving method which will only handle the {@link * MaxUploadSizeExceededException}. * * @param request the current HTTP request * @param response the response * @param handler the executed handler, which is null in case of an MaxUploadSizeExceededException * @param ex the exception that got thrown * @return the model and view or null if the exception is not a MaxUploadSizeExceededException or * no view is defined */ @Override public ModelAndView resolveException( HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { if (ex instanceof MaxUploadSizeExceededException) { String errorMessage = MessageHelper.getText( request, "error.blogpost.upload.filesize.limit", new Object[] {getHumanReadableUploadSizeLimit()}); String targetPath = ClientUrlHelper.removeIds(request.getServletPath() + request.getPathInfo()); String view = null; if (requestMappings != null) { view = requestMappings.get(targetPath); } if (view != null) { MessageHelper.saveErrorMessage(request, errorMessage); MessageHelper.setMessageTarget(request, targetPath); return new ModelAndView(ControllerHelper.replaceModuleInViewName(view)); } return prepareAjaxModelAndView(request, response, errorMessage); } return null; }