Subversion Repositories WebE

Compare Revisions

Last modification

Regard whitespace Rev 26 → Rev 27

/trunk/src/struts.xml
20,7 → 20,7
<result>/admin/userAddForm.jsp</result>
</action>
<action name="doUserAdd" method="add" class="ch.ffhs.webE.action.UserAction">
<action name="doUserAdd" method="addOrUpdate" class="ch.ffhs.webE.action.UserAction">
<result name="success">/admin/userAdd.jsp</result>
</action>
32,7 → 32,13
<result name="success" type="redirect">/admin/userList</result>
</action>
<action name="editUser" method="edit" class="ch.ffhs.webE.action.UserAction">
<result name="success">/admin/userAddForm.jsp</result>
</action>
<!-- Relationship Type management -->
<action name="relTypeList" method="list" class="ch.ffhs.webE.action.RelationshipTypeAction">
<result name="success">/admin/relTypeList.jsp</result>
42,7 → 48,7
<result>/admin/relTypeAddForm.jsp</result>
</action>
<action name="doRelTypeAdd" method="add" class="ch.ffhs.webE.action.RelationshipTypeAction">
<action name="doRelTypeAdd" method="addOrUpdate" class="ch.ffhs.webE.action.RelationshipTypeAction">
<result name="success" type="redirect">/admin/relTypeList</result>
</action>
50,6 → 56,11
<result name="success" type="redirect">/admin/relTypeList</result>
</action>
<action name="editRelType" method="edit" class="ch.ffhs.webE.action.RelationshipTypeAction">
<result name="success">/admin/relTypeAddForm.jsp</result>
<result name="error">/admin/adminError.jsp</result>
</action>
</package>
/trunk/src/ch/ffhs/webE/dao/UserDAO.java
4,10 → 4,16
 
import ch.ffhs.webE.domain.User;
 
public interface UserDAO {
public interface UserDAO
{
 
List<User> listUser();
void saveUser(User user);
 
User searchUsername(String username);
 
void deleteUser(int userId);
 
User listUserById(int userId);
 
void saveOrUpdateUser(User user);
}
/trunk/src/ch/ffhs/webE/dao/UserDAOImpl.java
38,7 → 38,8
e.printStackTrace();
}
 
//If no user was checked, return an empty list to mitigate null pointer exceptions
// If no user was checked, return an empty list to mitigate null pointer
// exceptions
if (user == null)
{
user = new ArrayList<User>();
54,11 → 55,11
* @return void
*/
@Override
public void saveUser(User user)
public void saveOrUpdateUser(User user)
{
try
{
session.save(user);
session.saveOrUpdate(user);
}
catch (Exception e)
{
112,4 → 113,22
}
return user;
}
 
/**
* Used to list a single user by Id.
*/
@Override
public User listUserById(int userId)
{
User user = null;
try
{
user = (User) session.get(User.class, userId);
}
catch (Exception e)
{
e.printStackTrace();
}
return user;
}
}
/trunk/src/ch/ffhs/webE/dao/RelationshipTypeDAO.java
8,8 → 8,9
 
List<RelationshipType> listRelationshipTypes();
 
boolean saveRelationshipType(RelationshipType relType);
 
boolean deleteRelationshipType(int relTypeID);
 
RelationshipType listRelTypeById(int relTypeID);
 
boolean saveOrUpdateRelType(RelationshipType relType);
}
/trunk/src/ch/ffhs/webE/dao/RelationshipTypeDAOImpl.java
57,11 → 57,11
* relationshipType
*/
@Override
public boolean saveRelationshipType(RelationshipType relType)
public boolean saveOrUpdateRelType(RelationshipType relType)
{
try
{
session.save(relType);
session.saveOrUpdate(relType);
return true;
}
catch (Exception e)
83,8 → 83,9
{
try
{
User user = (User) session.get(RelationshipType.class, relTypeID);
session.delete(user);
RelationshipType relType = (RelationshipType) session.get(
RelationshipType.class, relTypeID);
session.delete(relType);
return true;
}
catch (Exception e)
94,4 → 95,24
return false;
}
}
 
/**
* Used to get a relationship type by ID
*/
@Override
public RelationshipType listRelTypeById(int relTypeID)
{
RelationshipType relType = null;
try
{
relType = (RelationshipType) session.get(RelationshipType.class,
relTypeID);
}
catch (Exception e)
{
e.printStackTrace();
// TODO: Logging
}
return relType;
}
}
/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;
}
 
43,20 → 43,32
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)
{
/trunk/WebContent/admin/userAdd.jsp
1,6 → 1,6
<html>
<head>
<title>User bearbeiten</title>
<title>User added</title>
</head>
<body>
 
/trunk/WebContent/admin/userAddForm.jsp
8,13 → 8,15
<h1>User hinzuf&uuml;gen</h1>
<p>Bitte geben Sie die Benutzerdaten ein</p>
<s:form action="doUserAdd">
<s:textfield name="username" label="User Name" />
<s:password name="password" label="Password" />
<s:textfield name="firstname" label="Vorname" />
<s:textfield name="lastname" label="Nachname" />
<s:checkbox name="admin"
<s:hidden name="user.id" />
<s:textfield name="user.username" label="User Name" />
<s:password name="user.password" label="Password" />
<s:textfield name="user.firstname" label="Vorname" />
<s:textfield name="user.lastname" label="Nachname" />
<s:checkbox name="user.admin"
label="Soll der User admin sein?" />
<s:submit value="Add" />
</s:form>
</body>
</html>
/trunk/WebContent/admin/relTypeAdd.jsp
1,13 → 1,11
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
<title>Beziehungstyp added</title>
</head>
<body>
 
<h1>Beziehungstyp hinzugef&uuml;gt</h1>
<p>Der Beziehungstyp wurde hinzugef&uuml;gt</p>
<p>TODO: Weiterleitung!!</p>
</body>
</html>
/trunk/WebContent/admin/relTypeList.jsp
13,8 → 13,8
</s:if>
<table>
<tr>
<th>Bezeichnung nach A</th>
<th>Bezeichnung nach B</th>
<th>Bezeichnung A =&lt; B</th>
<th>Bezeichnung B =&lt; A</th>
</tr>
<s:iterator value="relTypeList" status="stat">
<tr>
22,10 → 22,10
<td><s:property value="nameTo" /></td>
<td><s:url id="editURL" action="editRelType">
<s:param name="id" value="%{id}"></s:param>
<s:param name="id" value="%{relationshipId}"></s:param>
</s:url> <s:a href="%{editURL}">&Auml;ndern</s:a></td>
<td><s:url id="deleteURL" action="deleteRelType">
<s:param name="id" value="%{id}"></s:param>
<s:param name="id" value="%{relationshipId}"></s:param>
</s:url> <s:a href="%{deleteURL}">L&ouml;schen</s:a></td>
</tr>
</s:iterator>
/trunk/WebContent/admin/relTypeAddForm.jsp
8,8 → 8,9
<h1>Beziehungstyp hinzuf&uuml;gen</h1>
<p>Bitte geben Sie die Daten f&uuml;r den Beziehungstypen ein</p>
<s:form action="doRelTypeAdd">
<s:textfield name="nameFrom" label="Name vom Ausgangspunkt (z.B. ist Vater von)" />
<s:textfield name="nameTo" label="Name vom Zielpunkt (z.B. ist Sohn von)" />
<s:hidden name="relType.relationshipId" />
<s:textfield name="relType.nameFrom" label="Name vom Ausgangspunkt (z.B. ist Vater von)" />
<s:textfield name="relType.nameTo" label="Name vom Zielpunkt (z.B. ist Sohn von)" />
<s:submit value="Add" />
</s:form>
</body>
/trunk/WebContent/admin/adminError.jsp
0,0 → 1,9
<html>
<head>
<title>Fehler</title>
</head>
<body>
 
<p>Es ist ein Fehler aufgetreten. Bitte gehen Sie zurück und versuchen Sie es erneut. Wir bitten um Entschuldigung</p>
</body>
</html>
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property