[jboss-svn-commits] JBL Code SVN: r29069 - labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 26 09:28:46 EDT 2009
Author: lkrzyzanek
Date: 2009-08-26 09:28:46 -0400 (Wed, 26 Aug 2009)
New Revision: 29069
Modified:
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java
Log:
Added handling exception when creating document from forum posts
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java 2009-08-26 13:27:56 UTC (rev 29068)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java 2009-08-26 13:28:46 UTC (rev 29069)
@@ -304,17 +304,22 @@
ForumThread thread = null;
Poll poll = null;
if (!topic.isContainsPoll()) {
- thread = createForumThread(community, rootMessageUser, topic,
- topicPost);
+ try {
+ thread = createForumThread(community, rootMessageUser, topic,
+ topicPost);
+ // add activity
+ ActivityBean activity = createActivity(thread, thread
+ .getJiveContainer(), thread.getUser(), Activity.Type.created,
+ thread.getCreationDate());
- // add activity
- ActivityBean activity = createActivity(thread, thread
- .getJiveContainer(), thread.getUser(), Activity.Type.created,
- thread.getCreationDate());
+ activitiesFromMigration.add(activity);
- activitiesFromMigration.add(activity);
+ postsCount++;
+ } catch (Exception e) {
+ log.error("Cannot create forum thread. Going to next topic");
+ continue;
+ }
- postsCount++;
} else {
log.trace("Migrate poll");
NukesPollBean nukesPoll = nukesForumsDAO.loadPoll(topic.getTopicID());
@@ -373,7 +378,15 @@
newUsersCount++;
}
- org.w3c.dom.Document replyBody = createDocument(reply.getBody());
+ org.w3c.dom.Document replyBody;
+ try {
+ replyBody = createDocument(reply.getBody());
+ } catch (Exception e) {
+ log.error("Cannot parse reply body for thread reply. "
+ + "Going to next reply. post_id: " + reply.getPostID());
+ log.error("Post body: " + reply.getBody());
+ continue;
+ }
Date replyDate = reply.getTime();
if (replyDate == null || replyDate.after(now)) {
replyDate = new Date(topicPost.getTime().getTime() + 1);
@@ -490,7 +503,15 @@
Announcement announcement = announcementManager.createAnnouncement(user,
jiveContainer);
announcement.setSubject(topicPost.getSubject());
- org.w3c.dom.Document topicBody = createDocument(topicPost.getBody());
+ org.w3c.dom.Document topicBody;
+ try {
+ topicBody = createDocument(topicPost.getBody());
+ } catch (Exception e) {
+ log.error("Cannot parse topic body for announcement. "
+ + "Going to next topic. topic_id: " + topic.getTopicID());
+ log.error("Topic body: " + topicPost.getBody());
+ return;
+ }
announcement.setBody(topicBody);
announcement.setStartDate(topicPost.getTime());
@@ -511,7 +532,7 @@
private ForumThread createForumThread(Community community,
User rootMessageUser, NukesForumsTopicBean topic,
- NukesForumsPostBean topicPost) {
+ NukesForumsPostBean topicPost) throws Exception {
ForumMessage rootMessage = forumManager.createMessage(community,
rootMessageUser);
// creationDate taken from first post.
@@ -520,7 +541,16 @@
rootMessage.setModificationDate(topicPost.getTime());
rootMessage.setSubject(topic.getTitle());
- org.w3c.dom.Document topicBody = createDocument(topicPost.getBody());
+ org.w3c.dom.Document topicBody;
+ try {
+ topicBody = createDocument(topicPost.getBody());
+ } catch (Exception e) {
+ log.error("Cannot parse topic body for forum thread. "
+ + "Going to next topic. topic_id: " + topic.getTopicID());
+ log.error("Topic body: " + topicPost.getBody());
+ throw e;
+ }
+
rootMessage.setBody(topicBody);
ForumThread thread = forumManager.createThread(community, rootMessage);
@@ -647,9 +677,11 @@
*
* @param text
* @return
+ * @throws Exception
+ * if some error occur during parsing text
*/
- protected org.w3c.dom.Document createDocument(String textBody) {
-
+ protected org.w3c.dom.Document createDocument(String textBody)
+ throws Exception {
for (TextConverter converter : converters) {
textBody = converter.convert(textBody);
}
More information about the jboss-svn-commits
mailing list