| 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.PluginProperties; |
| 36 |
|
import net.sourceforge.pebble.domain.BlogServiceException; |
| 37 |
|
import net.sourceforge.pebble.domain.Blog; |
| 38 |
|
import net.sourceforge.pebble.plugins.PluginConfigType; |
| 39 |
|
import net.sourceforge.pebble.web.controller.RequireSecurityToken; |
| 40 |
|
import net.sourceforge.pebble.web.view.ForwardView; |
| 41 |
|
import net.sourceforge.pebble.web.view.View; |
| 42 |
|
|
| 43 |
|
import javax.servlet.ServletException; |
| 44 |
|
import javax.servlet.http.HttpServletRequest; |
| 45 |
|
import javax.servlet.http.HttpServletResponse; |
| 46 |
|
import java.util.Enumeration; |
| 47 |
|
import java.util.Properties; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
@author |
| 53 |
|
|
| 54 |
|
@RequireSecurityToken |
|
|
|
| 0% |
Uncovered Elements: 43 (43) |
Complexity: 12 |
Complexity Density: 0,41 |
|
| 55 |
|
public class SavePluginsAction extends SecureAction { |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
@param |
| 61 |
|
@param |
| 62 |
|
@return |
| 63 |
|
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 11 |
Complexity Density: 0,39 |
|
| 64 |
0
|
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... |
| 65 |
0
|
Blog blog = (Blog)getModel().get(Constants.BLOG_KEY); |
| 66 |
|
|
| 67 |
0
|
String submit = request.getParameter("submit"); |
| 68 |
0
|
if (submit != null && submit.length() > 0) { |
| 69 |
0
|
Properties pluginProperties = blog.getPluginProperties().getProperties(); |
| 70 |
0
|
Enumeration params = request.getParameterNames(); |
| 71 |
0
|
while (params.hasMoreElements()) { |
| 72 |
0
|
String key = (String)params.nextElement(); |
| 73 |
|
|
| 74 |
0
|
if (key.equals("submit")) { |
| 75 |
|
|
| 76 |
0
|
} else if (key.startsWith(PluginConfigType.PLUGIN_PROPERTY_NAME_PREFIX)) { |
| 77 |
0
|
String value = request.getParameterValues(key)[0]; |
| 78 |
0
|
String property = key.substring(PluginConfigType.PLUGIN_PROPERTY_NAME_PREFIX.length()); |
| 79 |
0
|
if (value == null || value.length() == 0) |
| 80 |
|
{ |
| 81 |
0
|
pluginProperties.remove(property); |
| 82 |
|
} |
| 83 |
|
else |
| 84 |
|
{ |
| 85 |
0
|
pluginProperties.setProperty(property, value); |
| 86 |
|
} |
| 87 |
|
} else { |
| 88 |
|
|
| 89 |
0
|
String[] values = request.getParameterValues(key); |
| 90 |
0
|
if (values == null || values.length == 0) { |
| 91 |
0
|
blog.removeProperty(key); |
| 92 |
|
} else { |
| 93 |
0
|
StringBuilder builder = new StringBuilder(); |
| 94 |
0
|
String separator = ""; |
| 95 |
0
|
for (String value : values) |
| 96 |
|
{ |
| 97 |
0
|
builder.append(separator).append(value); |
| 98 |
0
|
separator = "\n"; |
| 99 |
|
} |
| 100 |
0
|
blog.setProperty(key, builder.toString()); |
| 101 |
|
} |
| 102 |
|
} |
| 103 |
|
} |
| 104 |
|
|
| 105 |
0
|
try { |
| 106 |
0
|
blog.storeProperties(); |
| 107 |
0
|
blog.getPluginProperties().store(); |
| 108 |
|
} catch (BlogServiceException e) { |
| 109 |
0
|
throw new ServletException(e); |
| 110 |
|
} |
| 111 |
|
} |
| 112 |
|
|
| 113 |
0
|
return new ForwardView("/reloadBlog.secureaction?redirectUrl=/aboutBlog.secureaction"); |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
@return |
| 120 |
|
@param |
| 121 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 122 |
0
|
public String[] getRoles(HttpServletRequest request) {... |
| 123 |
0
|
return new String[]{ |
| 124 |
|
Constants.BLOG_ADMIN_ROLE, |
| 125 |
|
Constants.BLOG_OWNER_ROLE |
| 126 |
|
}; |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
} |