| 1 |
|
package net.sourceforge.pebble.web.action; |
| 2 |
|
|
| 3 |
|
import net.sourceforge.pebble.Constants; |
| 4 |
|
import net.sourceforge.pebble.api.confirmation.TrackBackConfirmationStrategy; |
| 5 |
|
import net.sourceforge.pebble.domain.*; |
| 6 |
|
import net.sourceforge.pebble.web.view.NotFoundView; |
| 7 |
|
import net.sourceforge.pebble.web.view.View; |
| 8 |
|
import net.sourceforge.pebble.web.view.impl.ConfirmTrackBackView; |
| 9 |
|
import net.sourceforge.pebble.web.view.impl.TrackBackLinkView; |
| 10 |
|
import org.apache.commons.logging.Log; |
| 11 |
|
import org.apache.commons.logging.LogFactory; |
| 12 |
|
|
| 13 |
|
import javax.servlet.ServletException; |
| 14 |
|
import javax.servlet.http.HttpServletRequest; |
| 15 |
|
import javax.servlet.http.HttpServletResponse; |
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
@author |
| 21 |
|
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 5 |
Complexity Density: 0,26 |
|
| 22 |
|
public class GenerateTrackBackLinkAction extends AbstractTrackBackAction { |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
private static Log log = LogFactory.getLog(GenerateTrackBackLinkAction.class); |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
@param |
| 31 |
|
@param |
| 32 |
|
@return |
| 33 |
|
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 5 |
Complexity Density: 0,26 |
|
| 34 |
0
|
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... |
| 35 |
0
|
Blog blog = (Blog)getModel().get(Constants.BLOG_KEY); |
| 36 |
0
|
BlogEntry blogEntry; |
| 37 |
|
|
| 38 |
0
|
String entry = request.getParameter("entry"); |
| 39 |
0
|
BlogService service = new BlogService(); |
| 40 |
0
|
try { |
| 41 |
0
|
blogEntry = service.getBlogEntry(blog, entry); |
| 42 |
|
} catch (BlogServiceException e) { |
| 43 |
0
|
throw new ServletException(e); |
| 44 |
|
} |
| 45 |
0
|
if (blogEntry == null) { |
| 46 |
|
|
| 47 |
|
|
| 48 |
0
|
return new NotFoundView(); |
| 49 |
0
|
} else if (!blogEntry.isTrackBacksEnabled()) { |
| 50 |
0
|
return new NotFoundView(); |
| 51 |
|
} |
| 52 |
0
|
getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry); |
| 53 |
|
|
| 54 |
0
|
TrackBackConfirmationStrategy strategy = blog.getTrackBackConfirmationStrategy(); |
| 55 |
|
|
| 56 |
0
|
if (strategy.confirmationRequired(blog)) { |
| 57 |
0
|
request.getSession().setAttribute(BLOG_ENTRY_ID, blogEntry.getId()); |
| 58 |
0
|
strategy.setupConfirmation(request); |
| 59 |
0
|
return new ConfirmTrackBackView(); |
| 60 |
|
} else { |
| 61 |
0
|
generateTrackBackLink(blogEntry); |
| 62 |
0
|
return new TrackBackLinkView(); |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
} |