String comment = new String();
if(servletPath.equals("/admin/feedbacks/save")) {
if(session.getAttribute("admin") != null && session.getAttribute("admin").equals("true")) {
Feedback feedback = new Feedback();
MultipartRequest multi = new MultipartRequest(request, "/home/buzz/NetBeansProjects/bweb/web/images/");
feedback.setFromId(new Integer(multi.getParameter("newFromUser")));
feedback.setToId(new Integer(multi.getParameter("newToUser")));
String mode = multi.getParameter("commMode");
if(mode.equals("text")) {
feedback.setText(multi.getParameter("newTextComm"));
}
else if(mode.equals("file")) {
File f = multi.getFile("newFileComm");
if( f != null ) {
InputStream in = new FileInputStream(f);
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = reader.readLine()) != null) {
comment += line;
}
} catch (IOException e) {
} finally {
if (in != null) in.close();
}
}
feedback.setText(comment);
}
feedback.setScore(new Integer(multi.getParameter("newScore")));
feedback.save();
}
}
else if(servletPath.equals("/admin/feedbacks/update")) {
if(session.getAttribute("admin") != null && session.getAttribute("admin").equals("true")) {
Feedback feedback = new Feedback();
MultipartRequest multi = new MultipartRequest(request, "/home/buzz/NetBeansProjects/bweb/web/images/");
feedback.setId(new Integer(multi.getParameter("editId")));
feedback.setFromId(new Integer(multi.getParameter("editFromUser")));
feedback.setToId(new Integer(multi.getParameter("editToUser")));
String mode = multi.getParameter("commMode");
if(mode.equals("text")) {
feedback.setText(multi.getParameter("editTextComm"));
}
else if(mode.equals("file")) {
File f = multi.getFile("editFileComm");
if( f != null ) {
InputStream in = new FileInputStream(f);
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = reader.readLine()) != null) {
comment += line;
}
} catch (IOException e) {
} finally {
if (in != null) in.close();
}
}
feedback.setText(comment);
}
feedback.setScore(new Integer(multi.getParameter("editScore")));
feedback.update();
}
}
response.sendRedirect(request.getContextPath() + "/admin/feedbacks");