Rev 26 | Rev 34 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 26 | Rev 27 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | public RelationshipType getModel() |
29 | public RelationshipType getModel() |
30 | {
|
30 | {
|
31 | return relType; |
31 | return relType; |
32 | }
|
32 | }
|
33 | 33 | ||
34 | public String add() |
34 | public String addOrUpdate() |
35 | {
|
35 | {
|
36 | relTypeDAO.saveRelationshipType(relType); |
36 | relTypeDAO.saveOrUpdateRelType(relType); |
37 | return SUCCESS; |
37 | return SUCCESS; |
38 | }
|
38 | }
|
39 | 39 | ||
40 | public String list() |
40 | public String list() |
41 | {
|
41 | {
|
42 | relTypeList = relTypeDAO.listRelationshipTypes(); |
42 | relTypeList = relTypeDAO.listRelationshipTypes(); |
43 | return SUCCESS; |
43 | return SUCCESS; |
44 | }
|
44 | }
|
45 | 45 | ||
- | 46 | public String edit() |
|
- | 47 | {
|
|
- | 48 | int id = getIdParameter(); |
|
- | 49 | ||
- | 50 | if (id > 0) |
|
- | 51 | {
|
|
- | 52 | relType = relTypeDAO.listRelTypeById(id); |
|
- | 53 | return SUCCESS; |
|
- | 54 | }
|
|
- | 55 | else
|
|
- | 56 | {
|
|
- | 57 | return ERROR; |
|
- | 58 | }
|
|
- | 59 | }
|
|
- | 60 | ||
46 | /**
|
61 | /**
|
47 | * deletes a relationshipType, gets the ID from the id parameter that was
|
62 | * Gets the ID Parameter for update / delete requests
|
48 | * submitted
|
- | |
49 | *
|
63 | *
|
50 | * @return String - either success or error
|
64 | * @return int from the ID request. If not set or wrong, it gives back -1
|
51 | */
|
65 | */
|
52 | public String delete() |
66 | private int getIdParameter() |
53 | {
|
67 | {
|
54 | HttpServletRequest request = (HttpServletRequest) ActionContext |
68 | HttpServletRequest request = (HttpServletRequest) ActionContext |
55 | .getContext().get(ServletActionContext.HTTP_REQUEST); |
69 | .getContext().get(ServletActionContext.HTTP_REQUEST); |
56 | 70 | ||
57 | //Make sure the ID from the request parameter is valid
|
- | |
58 | int id = 0; |
71 | int id = -1; |
59 | - | ||
60 | try
|
72 | try
|
61 | {
|
73 | {
|
62 | id = Integer.parseInt(request.getParameter("id")); |
74 | id = Integer.parseInt(request.getParameter("id")); |
63 | }
|
75 | }
|
64 | catch (Exception e) |
76 | catch (Exception e) |
65 | {
|
77 | {
|
66 | return ERROR; |
78 | // TODO: Logging - wrong parameter set
|
67 | }
|
79 | }
|
68 | 80 | ||
- | 81 | return id; |
|
- | 82 | }
|
|
- | 83 | ||
- | 84 | /**
|
|
- | 85 | * deletes a relationshipType, gets the ID from the id parameter that was
|
|
- | 86 | * submitted
|
|
- | 87 | *
|
|
- | 88 | * @return String - either success or error
|
|
- | 89 | */
|
|
- | 90 | public String delete() |
|
- | 91 | {
|
|
- | 92 | int id = getIdParameter(); |
|
- | 93 | ||
69 | // Check for malicious ID values
|
94 | // Check for malicious ID values
|
70 | if (id > 0) |
95 | if (id > 0) |
71 | {
|
96 | {
|
72 | relTypeDAO.deleteRelationshipType(id); |
97 | relTypeDAO.deleteRelationshipType(id); |
73 | return SUCCESS; |
98 | return SUCCESS; |