1 package fr.paris.lutece.plugins.blog.web.admindashboard;
2
3 import fr.paris.lutece.plugins.blog.service.BlogParameterService;
4 import fr.paris.lutece.portal.business.rbac.RBAC;
5 import fr.paris.lutece.portal.service.rbac.RBACService;
6 import fr.paris.lutece.portal.service.security.SecurityTokenService;
7 import fr.paris.lutece.portal.service.user.AdminUserResourceIdService;
8 import fr.paris.lutece.portal.util.mvc.admin.annotations.Controller;
9 import javax.servlet.http.HttpServletRequest;
10 import fr.paris.lutece.portal.util.mvc.admin.MVCAdminJspBean;
11 import fr.paris.lutece.portal.business.user.AdminUser;
12 import fr.paris.lutece.portal.service.admin.AccessDeniedException;
13 import fr.paris.lutece.portal.web.dashboard.AdminDashboardJspBean;
14
15
16
17
18 @Controller( controllerJsp = "ManageAdminDashboard.jsp", controllerPath = "jsp/admin/plugins/blog/", right = "BLOG_ADVANCED_CONFIGURATION" )
19 public class BlogAdminDashboardJspBean extends MVCAdminJspBean
20 {
21 private static final long serialVersionUID = 3045411044102177294L;
22 private static final String UNAUTHORIZED = "Unauthorized";
23
24 public String doModifyBlogAdvancedParameters( HttpServletRequest request ) throws AccessDeniedException
25 {
26 if ( !SecurityTokenService.getInstance( ).validate( request, AdminDashboardJspBean.TEMPLATE_MANAGE_DASHBOARDS ) )
27 {
28 throw new AccessDeniedException( ERROR_INVALID_TOKEN );
29 }
30 if ( !RBACService.isAuthorized( AdminUser.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, AdminUserResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS,
31 getUser( ) ) )
32 {
33 throw new AccessDeniedException( UNAUTHORIZED );
34 }
35
36 BlogParameterService blogParameterService = BlogParameterService.getInstance();
37 blogParameterService.updateNumberMandatoryTags(request.getParameter( BlogParameterService.MARK_DEFAULT_NUMBER_MANDATORY_TAGS ) );
38 blogParameterService.updateDefaultDateEndPublishing(request.getParameter( BlogParameterService.MARK_DEFAULT_DATE_END_PUBLISHING ) );
39 blogParameterService.updateDefaultEditor(request.getParameter( BlogParameterService.MARK_DEFAULT_EDITOR ) );
40 blogParameterService.updateUseUploadImagePlugin( request.getParameter( BlogParameterService.MARK_USE_UPLOAD_IMAGE_PLUGIN ) != null );
41 blogParameterService.updateUseContentType( request.getParameter( BlogParameterService.MARK_USE_CONTENT_TYPE ) != null );
42 blogParameterService.updateAcceptedFileTypes( request.getParameter( BlogParameterService.MARK_ACCEPTED_FILE_TYPES ) );
43
44 return getAdminDashboardsUrl( request, BlogAdminDashboardComponent.ANCHOR_ADMIN_DASHBOARDS );
45 }
46 }