Date now = new Date();
String webFormType = webForm.getFormType();
String webFormId = webForm.getWebFormId();
UserComment userComments = new UserComment();
userComments.setUserId(userid);
userComments.setCommentUserId(userid);
userComments.setDate(now);
if (request.getParameter("comments")!=null) {
userComments.setComment(request.getParameter("comments"));
}
else if(UtilMethods.isSet(webForm.getFormType())) {
userComments.setSubject("User submitted: " + webFormType);
userComments.setComment("Web Form: " + webFormType + " - ID: " + webFormId);
}
else{
userComments.setSubject("User submitted Form: Open Entry ");
StringBuffer buffy = new StringBuffer();
Enumeration x = request.getParameterNames();
while(x.hasMoreElements()){
String key = (String) x.nextElement();
buffy.append(key);
buffy.append(":\t");
buffy.append(request.getParameter(key));
buffy.append("\n");
if(buffy.length() > 65000){
break;
}
}
userComments.setComment(buffy.toString());
}
userComments.setTypeComment(UserComment.TYPE_INCOMING);
userComments.setMethod(UserComment.METHOD_WEB);
userComments.setCommunicationId(null);
UserCommentsFactory.saveUserComment(userComments);
}