user and relationship type now editable and removeable. Generic error page for admin site
/trunk/src/ch/ffhs/webE/action/RelationshipTypeAction.java |
---|
31,9 → 31,9 |
return relType; |
} |
public String add() |
public String addOrUpdate() |
{ |
relTypeDAO.saveRelationshipType(relType); |
relTypeDAO.saveOrUpdateRelType(relType); |
return SUCCESS; |
} |
42,21 → 42,33 |
relTypeList = relTypeDAO.listRelationshipTypes(); |
return SUCCESS; |
} |
public String edit() |
{ |
int id = getIdParameter(); |
if (id > 0) |
{ |
relType = relTypeDAO.listRelTypeById(id); |
return SUCCESS; |
} |
else |
{ |
return ERROR; |
} |
} |
/** |
* deletes a relationshipType, gets the ID from the id parameter that was |
* submitted |
* Gets the ID Parameter for update / delete requests |
* |
* @return String - either success or error |
* @return int from the ID request. If not set or wrong, it gives back -1 |
*/ |
public String delete() |
private int getIdParameter() |
{ |
HttpServletRequest request = (HttpServletRequest) ActionContext |
.getContext().get(ServletActionContext.HTTP_REQUEST); |
//Make sure the ID from the request parameter is valid |
int id = 0; |
int id = -1; |
try |
{ |
id = Integer.parseInt(request.getParameter("id")); |
63,9 → 75,22 |
} |
catch (Exception e) |
{ |
return ERROR; |
// TODO: Logging - wrong parameter set |
} |
return id; |
} |
/** |
* deletes a relationshipType, gets the ID from the id parameter that was |
* submitted |
* |
* @return String - either success or error |
*/ |
public String delete() |
{ |
int id = getIdParameter(); |
// Check for malicious ID values |
if (id > 0) |
{ |
/trunk/src/ch/ffhs/webE/action/UserAction.java |
---|
35,9 → 35,9 |
* |
* @return |
*/ |
public String add() |
public String addOrUpdate() |
{ |
userDAO.saveUser(user); |
userDAO.saveOrUpdateUser(user); |
return SUCCESS; |
} |
52,19 → 52,32 |
return SUCCESS; |
} |
public String edit() |
{ |
int id = getIdParameter(); |
if (id > 0) |
{ |
user = userDAO.listUserById(id); |
return SUCCESS; |
} |
else |
{ |
return ERROR; |
} |
} |
/** |
* deletes a user, gets the ID from the "id" parameter that was submitted |
* with the HTTP request |
* Gets the ID Parameter for update / delete requests |
* |
* @return String - either SUCCESS or ERROR constant |
* @return int from the ID request. If not set or wrong, it gives back -1 |
*/ |
public String delete() |
private int getIdParameter() |
{ |
HttpServletRequest request = (HttpServletRequest) ActionContext |
.getContext().get(ServletActionContext.HTTP_REQUEST); |
int id = 0; |
int id = -1; |
try |
{ |
id = Integer.parseInt(request.getParameter("id")); |
71,9 → 84,23 |
} |
catch (Exception e) |
{ |
return ERROR; |
// TODO: Logging - wrong parameter set |
} |
return id; |
} |
/** |
* deletes a user, gets the ID from the "id" parameter that was submitted |
* with the HTTP request |
* |
* @return String - either SUCCESS or ERROR constant |
*/ |
public String delete() |
{ |
int id = getIdParameter(); |
// Check for malicious ID values |
if (id > 0) |
{ |