| 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.dao.CategoryDAO; |
| 36 |
|
import net.sourceforge.pebble.dao.DAOFactory; |
| 37 |
|
import net.sourceforge.pebble.dao.PersistenceException; |
| 38 |
|
import net.sourceforge.pebble.domain.Category; |
| 39 |
|
import net.sourceforge.pebble.domain.Blog; |
| 40 |
|
import net.sourceforge.pebble.web.controller.RequireSecurityToken; |
| 41 |
|
import net.sourceforge.pebble.web.view.ForwardView; |
| 42 |
|
import net.sourceforge.pebble.web.view.View; |
| 43 |
|
|
| 44 |
|
import javax.servlet.ServletException; |
| 45 |
|
import javax.servlet.http.HttpServletRequest; |
| 46 |
|
import javax.servlet.http.HttpServletResponse; |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
@author |
| 52 |
|
|
| 53 |
|
@RequireSecurityToken |
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 7 |
Complexity Density: 0,27 |
|
| 54 |
|
public class SaveCategoryAction extends SecureAction { |
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
@param |
| 60 |
|
@param |
| 61 |
|
@return |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 6 |
Complexity Density: 0,24 |
|
| 63 |
0
|
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... |
| 64 |
0
|
Blog blog = (Blog)getModel().get(Constants.BLOG_KEY); |
| 65 |
0
|
String id = request.getParameter("id"); |
| 66 |
0
|
String name = request.getParameter("name"); |
| 67 |
0
|
String tags = request.getParameter("tags"); |
| 68 |
|
|
| 69 |
0
|
if (id != null && id.trim().length() > 0) { |
| 70 |
0
|
Category category = blog.getCategory(id); |
| 71 |
0
|
if (category == null) { |
| 72 |
|
|
| 73 |
0
|
category = new Category(); |
| 74 |
0
|
category.setId(id); |
| 75 |
0
|
category.setName(name); |
| 76 |
0
|
blog.addCategory(category); |
| 77 |
0
|
category.setTags(tags); |
| 78 |
0
|
try { |
| 79 |
|
|
| 80 |
0
|
DAOFactory factory = DAOFactory.getConfiguredFactory(); |
| 81 |
0
|
CategoryDAO dao = factory.getCategoryDAO(); |
| 82 |
0
|
dao.addCategory(category, blog); |
| 83 |
|
} catch (PersistenceException pe) { |
| 84 |
0
|
pe.printStackTrace(); |
| 85 |
|
} |
| 86 |
|
} else { |
| 87 |
|
|
| 88 |
0
|
category.setName(name); |
| 89 |
0
|
category.setTags(tags); |
| 90 |
0
|
try { |
| 91 |
|
|
| 92 |
0
|
DAOFactory factory = DAOFactory.getConfiguredFactory(); |
| 93 |
0
|
CategoryDAO dao = factory.getCategoryDAO(); |
| 94 |
0
|
dao.updateCategory(category, blog); |
| 95 |
|
} catch (PersistenceException pe) { |
| 96 |
0
|
pe.printStackTrace(); |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
|
} |
| 100 |
|
|
| 101 |
0
|
return new ForwardView("/viewCategories.secureaction"); |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
@return |
| 108 |
|
@param |
| 109 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
0
|
public String[] getRoles(HttpServletRequest request) {... |
| 111 |
0
|
return new String[]{Constants.BLOG_CONTRIBUTOR_ROLE}; |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
} |