| 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.Category; |
| 36 | |
import net.sourceforge.pebble.domain.Blog; |
| 37 | |
import net.sourceforge.pebble.util.Utilities; |
| 38 | |
import net.sourceforge.pebble.web.security.RequireSecurityToken; |
| 39 | |
import net.sourceforge.pebble.web.security.SecurityTokenValidatorCondition; |
| 40 | |
import net.sourceforge.pebble.web.view.ForwardView; |
| 41 | |
import net.sourceforge.pebble.web.view.View; |
| 42 | |
import net.sourceforge.pebble.web.view.impl.UtilitiesView; |
| 43 | |
|
| 44 | |
import javax.servlet.ServletException; |
| 45 | |
import javax.servlet.http.HttpServletRequest; |
| 46 | |
import javax.servlet.http.HttpServletResponse; |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
@RequireSecurityToken(UtilitiesAction.UtilitiesCondition.class) |
| 55 | 0 | public class UtilitiesAction extends SecureAction { |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException { |
| 65 | 0 | Blog blog = (Blog)getModel().get(Constants.BLOG_KEY); |
| 66 | 0 | String action = request.getParameter("action"); |
| 67 | 0 | if (action == null) { |
| 68 | |
|
| 69 | 0 | } else if (action.equalsIgnoreCase("ipAddressListener")) { |
| 70 | 0 | Utilities.buildIpAddressLists(blog); |
| 71 | 0 | return new ForwardView("/reloadBlog.secureaction"); |
| 72 | 0 | } else if (action.equalsIgnoreCase("fixHtmlInResponses")) { |
| 73 | 0 | Utilities.fixHtmlInResponses(blog); |
| 74 | 0 | return new ForwardView("/reloadBlog.secureaction"); |
| 75 | 0 | } else if (action.equalsIgnoreCase("buildIndexes")) { |
| 76 | 0 | Utilities.buildIndexes(blog); |
| 77 | 0 | return new ForwardView("/reloadBlog.secureaction"); |
| 78 | 0 | } else if (action.equalsIgnoreCase("convertCategories")) { |
| 79 | 0 | Utilities.convertCategories(blog); |
| 80 | 0 | return new ForwardView("/reloadBlog.secureaction"); |
| 81 | 0 | } else if (action.equalsIgnoreCase("restructureBlogToGMT")) { |
| 82 | 0 | Utilities.restructureBlogToGMT(blog); |
| 83 | 0 | Utilities.buildIndexes(blog); |
| 84 | 0 | return new ForwardView("/reloadBlog.secureaction"); |
| 85 | 0 | } else if (action.equalsIgnoreCase("moveBlogEntriesFromCategory")) { |
| 86 | 0 | Category from = blog.getCategory(request.getParameter("from")); |
| 87 | 0 | Category to = blog.getCategory(request.getParameter("to")); |
| 88 | 0 | if (from != null && to != null) { |
| 89 | 0 | Utilities.moveBlogEntriesFromCategory(blog, from, to); |
| 90 | |
} |
| 91 | |
} |
| 92 | |
|
| 93 | 0 | return new UtilitiesView(); |
| 94 | |
} |
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
public String[] getRoles(HttpServletRequest request) { |
| 103 | 0 | return new String[]{Constants.BLOG_ADMIN_ROLE, Constants.BLOG_OWNER_ROLE}; |
| 104 | |
} |
| 105 | |
|
| 106 | 0 | public static class UtilitiesCondition implements SecurityTokenValidatorCondition { |
| 107 | |
public boolean shouldValidate(HttpServletRequest request) { |
| 108 | |
|
| 109 | 0 | return request.getParameter("action") != null; |
| 110 | |
} |
| 111 | |
} |
| 112 | |
} |