| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
package net.sourceforge.pebble.web.action; |
| 33 |
|
|
| 34 |
|
import net.sourceforge.pebble.Constants; |
| 35 |
|
import net.sourceforge.pebble.domain.Blog; |
| 36 |
|
import net.sourceforge.pebble.domain.BlogServiceException; |
| 37 |
|
import net.sourceforge.pebble.web.controller.RequireSecurityToken; |
| 38 |
|
import net.sourceforge.pebble.web.view.RedirectView; |
| 39 |
|
import net.sourceforge.pebble.web.view.View; |
| 40 |
|
|
| 41 |
|
import javax.servlet.ServletException; |
| 42 |
|
import javax.servlet.http.HttpServletRequest; |
| 43 |
|
import javax.servlet.http.HttpServletResponse; |
| 44 |
|
import java.util.Enumeration; |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
@author |
| 50 |
|
|
| 51 |
|
@RequireSecurityToken |
|
|
|
| 0% |
Uncovered Elements: 47 (47) |
Complexity: 7 |
Complexity Density: 0,19 |
|
| 52 |
|
public class SaveBlogSecurityAction extends SecureAction { |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
@param |
| 58 |
|
@param |
| 59 |
|
@return |
| 60 |
|
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 6 |
Complexity Density: 0,17 |
|
| 61 |
0
|
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... |
| 62 |
0
|
Blog blog = (Blog)getModel().get(Constants.BLOG_KEY); |
| 63 |
|
|
| 64 |
0
|
String privateBlog = request.getParameter("private"); |
| 65 |
0
|
blog.setProperty(Blog.PRIVATE_KEY, privateBlog); |
| 66 |
|
|
| 67 |
0
|
String values[] = request.getParameterValues("blogOwners"); |
| 68 |
0
|
StringBuffer blogOwners = new StringBuffer(); |
| 69 |
0
|
if (values != null) { |
| 70 |
0
|
for (String value : values) { |
| 71 |
0
|
blogOwners.append(value); |
| 72 |
0
|
blogOwners.append(","); |
| 73 |
|
} |
| 74 |
|
} |
| 75 |
0
|
blog.setProperty(Blog.BLOG_OWNERS_KEY, blogOwners.toString()); |
| 76 |
|
|
| 77 |
0
|
values = request.getParameterValues("blogPublishers"); |
| 78 |
0
|
StringBuffer blogPublishers = new StringBuffer(); |
| 79 |
0
|
if (values != null) { |
| 80 |
0
|
for (String value : values) { |
| 81 |
0
|
blogPublishers.append(value); |
| 82 |
0
|
blogPublishers.append(","); |
| 83 |
|
} |
| 84 |
|
} |
| 85 |
0
|
blog.setProperty(Blog.BLOG_PUBLISHERS_KEY, blogPublishers.toString()); |
| 86 |
|
|
| 87 |
0
|
values = request.getParameterValues("blogContributors"); |
| 88 |
0
|
StringBuffer blogContributors = new StringBuffer(); |
| 89 |
0
|
if (values != null) { |
| 90 |
0
|
for (String value : values) { |
| 91 |
0
|
blogContributors.append(value); |
| 92 |
0
|
blogContributors.append(","); |
| 93 |
|
} |
| 94 |
|
} |
| 95 |
0
|
blog.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, blogContributors.toString()); |
| 96 |
|
|
| 97 |
0
|
values = request.getParameterValues("blogReaders"); |
| 98 |
0
|
StringBuffer blogReaders = new StringBuffer(); |
| 99 |
0
|
if (values != null) { |
| 100 |
0
|
for (String value : values) { |
| 101 |
0
|
blogReaders.append(value); |
| 102 |
0
|
blogReaders.append(","); |
| 103 |
|
} |
| 104 |
|
} |
| 105 |
0
|
blog.setProperty(Blog.BLOG_READERS_KEY, blogReaders.toString()); |
| 106 |
|
|
| 107 |
0
|
try { |
| 108 |
0
|
blog.storeProperties(); |
| 109 |
0
|
blog.info("Blog security settings saved."); |
| 110 |
|
} catch (BlogServiceException e) { |
| 111 |
0
|
throw new ServletException(e); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
0
|
return new RedirectView(blog.getUrl() + "viewBlogSecurity.secureaction"); |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
@return |
| 121 |
|
@param |
| 122 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 123 |
0
|
public String[] getRoles(HttpServletRequest request) {... |
| 124 |
0
|
return new String[]{ |
| 125 |
|
Constants.BLOG_ADMIN_ROLE, |
| 126 |
|
Constants.BLOG_OWNER_ROLE |
| 127 |
|
}; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
} |