| 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.*; |
| 36 |
|
import net.sourceforge.pebble.web.controller.RequireSecurityToken; |
| 37 |
|
import net.sourceforge.pebble.web.view.View; |
| 38 |
|
import net.sourceforge.pebble.web.view.NotFoundView; |
| 39 |
|
import net.sourceforge.pebble.web.view.impl.RemoveEmailAddressConfirmationView; |
| 40 |
|
import net.sourceforge.pebble.web.view.impl.RemoveEmailAddressView; |
| 41 |
|
import org.apache.commons.logging.Log; |
| 42 |
|
import org.apache.commons.logging.LogFactory; |
| 43 |
|
|
| 44 |
|
import javax.servlet.ServletException; |
| 45 |
|
import javax.servlet.http.HttpServletRequest; |
| 46 |
|
import javax.servlet.http.HttpServletResponse; |
| 47 |
|
import java.util.Iterator; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
@author |
| 53 |
|
|
| 54 |
|
@RequireSecurityToken |
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 9 |
Complexity Density: 0,38 |
|
| 55 |
|
public class RemoveEmailAddressAction extends Action { |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
private static Log log = LogFactory.getLog(RemoveEmailAddressAction.class); |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
@param |
| 64 |
|
@param |
| 65 |
|
@return |
| 66 |
|
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 9 |
Complexity Density: 0,38 |
|
| 67 |
0
|
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... |
| 68 |
0
|
Blog blog = (Blog)getModel().get(Constants.BLOG_KEY); |
| 69 |
0
|
BlogEntry blogEntry = null; |
| 70 |
0
|
Comment comment = null; |
| 71 |
|
|
| 72 |
0
|
String entry = request.getParameter("entry"); |
| 73 |
0
|
String email = request.getParameter("email"); |
| 74 |
|
|
| 75 |
0
|
BlogService service = new BlogService(); |
| 76 |
0
|
try { |
| 77 |
0
|
blogEntry = service.getBlogEntry(blog, entry); |
| 78 |
|
} catch (BlogServiceException e) { |
| 79 |
0
|
throw new ServletException(e); |
| 80 |
|
} |
| 81 |
0
|
if (blogEntry == null) { |
| 82 |
0
|
return new NotFoundView(); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
0
|
getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry); |
| 86 |
|
|
| 87 |
0
|
if (email != null && email.length() > 0) { |
| 88 |
|
|
| 89 |
0
|
Iterator it = blogEntry.getComments().iterator(); |
| 90 |
0
|
while (it.hasNext()) { |
| 91 |
0
|
comment = (Comment)it.next(); |
| 92 |
|
|
| 93 |
0
|
if (comment.getEmail() != null && comment.getEmail().equals(email)) { |
| 94 |
0
|
comment.setEmail(null); |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
|
|
| 98 |
0
|
try { |
| 99 |
0
|
service.putBlogEntry(blogEntry); |
| 100 |
|
} catch (BlogServiceException be) { |
| 101 |
0
|
log.error(be.getMessage(), be); |
| 102 |
0
|
throw new ServletException(be); |
| 103 |
|
} |
| 104 |
|
|
| 105 |
0
|
return new RemoveEmailAddressConfirmationView(); |
| 106 |
|
} else { |
| 107 |
0
|
return new RemoveEmailAddressView(); |
| 108 |
|
} |
| 109 |
|
} |
| 110 |
|
} |