[jboss-svn-commits] JBL Code SVN: r34771 - in labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk: src/changes and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 18 06:43:35 EDT 2010
Author: lkrzyzanek
Date: 2010-08-18 06:43:34 -0400 (Wed, 18 Aug 2010)
New Revision: 34771
Removed:
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/NukesUserBean.java
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/cache-config.xml
Modified:
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/pom.xml
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/changes/changes.xml
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/dao/DbNukesForumsDAOImpl.java
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/NukesForumsDAO.java
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/plugin.xml
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/spring.xml
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/test/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManagerTest.java
Log:
Upgraded to work with SBS 4.5.x
Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk
___________________________________________________________________
Name: svn:ignore
+ .settings
.project
.classpath
target
nukes-forums-migration-prod-env.jar
updateMapping.sql
spring-prod.xml
deploy.pom
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/pom.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/pom.xml 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/pom.xml 2010-08-18 10:43:34 UTC (rev 34771)
@@ -5,9 +5,9 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.labs.sbs.plugin</groupId>
<artifactId>nukes-forums-migration</artifactId>
- <name>SBS plugin: Nukes Forums migratjion</name>
+ <name>SBS plugin: Nukes Forums migration</name>
<description>Migration tool for movement Nukes Forums to SBS discussions</description>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<parent>
<groupId>org.jboss.labs</groupId>
@@ -183,15 +183,7 @@
<version>2.6</version>
</dependency>
</dependencies>
- <!--
- This is where you set the Jive SBS version your plugin is compiled
- against.
- -->
- <properties>
- <sbs.version>4.0.3</sbs.version>
- </properties>
-
<reporting>
<plugins>
<plugin>
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/changes/changes.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/changes/changes.xml 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/changes/changes.xml 2010-08-18 10:43:34 UTC (rev 34771)
@@ -9,6 +9,10 @@
</properties>
<body>
+ <release version="2.1.0" date="2010-08-18" description="Upgrade to work with SBS 4.5.x">
+ </release>
+
+
<release version="2.0.0" date="2010-02-23" description="Upgrade to work with SBS 4.x">
</release>
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 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java 2010-08-18 10:43:34 UTC (rev 34771)
@@ -25,7 +25,6 @@
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
@@ -41,48 +40,28 @@
import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsDAO;
import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsForumBean;
import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsMappingDAO;
-import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsPostBean;
-import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsTopicBean;
-import org.jboss.labs.clearspace.plugin.nfm.dao.NukesPollBean;
-import org.jboss.labs.clearspace.plugin.nfm.dao.NukesPollOptionBean;
import org.jboss.labs.clearspace.plugin.nfm.dao.ViewCountDAO;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.w3c.dom.Document;
-import com.jivesoftware.base.UnauthorizedException;
-import com.jivesoftware.base.User;
import com.jivesoftware.base.UserManager;
-import com.jivesoftware.base.UserNotFoundException;
-import com.jivesoftware.base.UserTemplate;
import com.jivesoftware.base.wiki.WikiContentHelper;
-import com.jivesoftware.community.Activity;
-import com.jivesoftware.community.ActivityBean;
-import com.jivesoftware.community.Announcement;
+import com.jivesoftware.cache.Cache;
import com.jivesoftware.community.AnnouncementManager;
import com.jivesoftware.community.Community;
import com.jivesoftware.community.CommunityManager;
import com.jivesoftware.community.CommunityNotFoundException;
-import com.jivesoftware.community.ContentTag;
import com.jivesoftware.community.ForumManager;
-import com.jivesoftware.community.ForumMessage;
-import com.jivesoftware.community.ForumThread;
-import com.jivesoftware.community.JiveContainer;
-import com.jivesoftware.community.JiveContentObject;
-import com.jivesoftware.community.JiveObject;
-import com.jivesoftware.community.Poll;
-import com.jivesoftware.community.PollManager;
import com.jivesoftware.community.QuestionManager;
-import com.jivesoftware.community.RejectedException;
import com.jivesoftware.community.TagManager;
-import com.jivesoftware.community.TagObjectNotFoundException;
import com.jivesoftware.community.WatchManager;
import com.jivesoftware.community.impl.dao.ActivityDAO;
+import com.jivesoftware.community.polls.PollManager;
import com.jivesoftware.community.renderer.impl.v2.HtmlRenderUtils;
import com.jivesoftware.community.renderer.impl.v2.JAXPUtils;
import com.jivesoftware.community.stats.ViewCountManager;
import com.jivesoftware.community.web.JiveResourceResolver;
-import com.jivesoftware.util.DateUtils;
import com.jivesoftware.util.StringUtils;
/**
@@ -93,8 +72,7 @@
*/
public class DbNukesForumsManager implements NukesForumsManager {
- private static final Logger log = LogManager
- .getLogger(DbNukesForumsManager.class);
+ private static final Logger log = LogManager.getLogger(DbNukesForumsManager.class);
private NukesForumsMappingDAO nukesForumsMappingDAO;
@@ -122,25 +100,20 @@
private PollManager pollManager;
- private NukesUserManager nukesUserManager;
-
/**
* Application context. Default = "/community"
*/
private String appContext = "/community";
- /**
- * Name of tag for sticky content
- */
private String stickyTagName = "sticky";
private Map<Long, Long> categoryMappings = null;
private Map<Long, Long> forumMappings = null;
- private com.jivesoftware.community.cache.Cache<Long, Long> topicMappings;
+ private Cache<Long, Long> topicMappings;
- private com.jivesoftware.community.cache.Cache<Long, Long> postMappings;
+ private Cache<Long, Long> postMappings;
private Date defaultTopicTime;
@@ -158,11 +131,9 @@
for (Map.Entry<Long, Long> entry : entries) {
Long catID = entry.getKey();
Long communityID = entry.getValue();
- log.debug("Create forum mapping for category ID: " + catID
- + " with default communityID: " + communityID);
+ log.debug("Create forum mapping for category ID: " + catID + " with default communityID: " + communityID);
- List<NukesForumsForumBean> forums = nukesForumsDAO
- .getAllForumsByCategoryID(catID);
+ List<NukesForumsForumBean> forums = nukesForumsDAO.getAllForumsByCategoryID(catID);
for (NukesForumsForumBean nukesForumsForumBean : forums) {
Long forumID = nukesForumsForumBean.getForumID();
@@ -170,8 +141,8 @@
nukesForumsMappingDAO.saveForumMapping(forumID, communityID);
count++;
} catch (DataIntegrityViolationException e) {
- log.warn("Saving forum mapping failed for forumID: " + forumID
- + ". Going to next forumID. Message: " + e.getMessage());
+ log.warn("Saving forum mapping failed for forumID: " + forumID + ". Going to next forumID. Message: "
+ + e.getMessage());
}
}
}
@@ -185,205 +156,13 @@
}
/**
- * Create announcement from topic announcement
- *
- * @param topic
- * @param topicPost
- * @param user
- * @param jiveContainer
- * @return true if announcement was successfully created if some error occur
- * then false
- * @throws UnauthorizedException
- * @throws RejectedException
- */
- private boolean createAnnouncement(NukesForumsTopicBean topic,
- NukesForumsPostBean topicPost, User user, JiveContainer jiveContainer)
- throws UnauthorizedException, RejectedException {
- Announcement announcement = announcementManager.createAnnouncement(user,
- jiveContainer);
- announcement.setSubject(topicPost.getSubject());
- 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 false;
- }
- announcement.setBody(topicBody);
- announcement.setStartDate(topicPost.getTime());
-
- // handle end date (expiration)
- Calendar cal = Calendar.getInstance();
- cal.setTime(announcement.getStartDate());
- cal.add(Calendar.MONTH, 3);
- Date possibleEndDate = cal.getTime();
-
- if (possibleEndDate.before(new Date())) {
- // Announcement is too old - expire it
- announcement.setEndDate(possibleEndDate);
- announcement.setStatus(JiveContentObject.Status.EXPIRED);
- }
-
- announcementManager.addAnnouncement(announcement);
- return true;
- }
-
- private ForumThread createForumThread(Community community,
- User rootMessageUser, NukesForumsTopicBean topic,
- NukesForumsPostBean topicPost) throws Exception {
- ForumMessage rootMessage = forumManager.createMessage(community,
- rootMessageUser);
- // creationDate taken from first post.
- // some topic time is not correct (in future etc.)
- rootMessage.setCreationDate(topicPost.getTime());
- rootMessage.setModificationDate(topicPost.getTime());
- rootMessage.setSubject(topic.getTitle());
-
- 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);
- thread.setCreationDate(topicPost.getTime());
- thread.setModificationDate(topicPost.getTime());
-
- try {
- forumManager.addThread(community, thread);
-
- nukesForumsMappingDAO
- .saveTopicMapping(topic.getTopicID(), thread.getID());
-
- nukesForumsMappingDAO.savePostMapping(topicPost.getPostID(), rootMessage
- .getID());
- if (topicPost.getSubject().contains("?")) {
- questionManager.createQuestion(thread);
- }
-
- if (topic.isSticky()) {
- log.trace("Adding sticky tag");
- ContentTag stickyTag;
- try {
- stickyTag = tagManager.getTag(stickyTagName);
- } catch (TagObjectNotFoundException e) {
- stickyTag = tagManager.createTag(stickyTagName);
- }
- tagManager.addTag(stickyTag, thread);
- }
- } catch (RejectedException e) {
- throw new RuntimeException(e);
- }
- return thread;
- }
-
- private Poll createPoll(NukesPollBean nukesPoll,
- NukesForumsPostBean topicPost, User user, JiveContainer jiveContainer) {
- Poll poll = pollManager.createPoll(jiveContainer.getObjectType(),
- jiveContainer.getID(), user, nukesPoll.getName());
- poll.setStartDate(topicPost.getTime());
- poll.setDescription(topicPost.getBody());
-
- List<NukesPollOptionBean> options = nukesPoll.getOptions();
-
- for (int i = 0; i < options.size(); i++) {
- poll.addOption(options.get(i).getName());
-
- }
-
- for (int i = 0; i < options.size(); i++) {
- NukesPollOptionBean option = options.get(i);
- for (int voteIndex = 0; voteIndex < option.getResult(); voteIndex++) {
- // uniqueID is optionID and voteIndex - we don't have IP address or
- // something like that.
- poll.addAnonymousVote(i, option.getOptionID() + "-" + voteIndex);
- }
- }
-
- poll.setEndDate(new Date());
- // beware - must be set at last. setEndate change expiration date!
- poll.setExpirationDate(DateUtils.getMaxDate());
-
- long pollMappingID = poll.getID() * -1;
-
- nukesForumsMappingDAO.saveTopicMapping(nukesPoll.getTopicID(),
- pollMappingID);
- nukesForumsMappingDAO.savePostMapping(topicPost.getPostID(), pollMappingID);
-
- return poll;
- }
-
- private ActivityBean createActivity(JiveObject object, JiveObject parent,
- User user, Activity.Type activityType, Date creationDate) {
- ActivityBean bean = new ActivityBean();
- bean.setTargetObjectID(object.getID());
- bean.setTargetObjectType(object.getObjectType());
- if (user != null) {
- bean.setUserID(user.getID());
- }
- if (parent != null) {
- bean.setContainerObjectID(parent.getID());
- bean.setContainerObjectType(parent.getObjectType());
- }
- bean.setType(activityType);
- bean.setCreationDate(creationDate);
-
- return bean;
- }
-
- private User findUser(String username, String email) {
- UserTemplate userTemplate = new UserTemplate(username);
- userTemplate.setEmail(email);
-
- return userManager.getUser(userTemplate);
- }
-
- private void migrateForumWatches(Long forumID, JiveObject objectToWatch) {
- List<String> users = nukesForumsDAO.getForumWatchingUses(forumID);
- for (String username : users) {
- try {
- User user = userManager.getUser(username);
- watchManager.createWatch(user, objectToWatch);
- } catch (UserNotFoundException e) {
- log.error("Unknown user for watching forum " + forumID + " username: "
- + username + ". Ommiting this watch.");
- } catch (Exception e) {
- log.error("Some unexpected exception. Going to next forum watch", e);
- }
- }
- }
-
- private void migrateTopicWatches(Long topicID, JiveObject objectToWatch) {
- List<String> users = nukesForumsDAO.getTopicWatchingUses(topicID);
- for (String username : users) {
- try {
- User user = userManager.getUser(username);
- watchManager.createWatch(user, objectToWatch);
- } catch (UserNotFoundException e) {
- log.error("Unknown user for watching topic " + topicID + " username: "
- + username + ". Ommiting this watch.");
- }
- }
- }
-
- /**
* Create document from string. body of document is converted via converters
*
* @param text
* @return
- * @throws Exception
- * if some error occur during parsing text
+ * @throws Exception if some error occur during parsing text
*/
- protected org.w3c.dom.Document createDocument(String textBody)
- throws Exception {
+ protected org.w3c.dom.Document createDocument(String textBody) throws Exception {
for (TextConverter converter : converters) {
textBody = converter.convert(textBody);
}
@@ -407,8 +186,7 @@
throw new UnsupportedEncodingException("unable to tidy document");
}
Document document = JAXPUtils.toBodyXml(html);
- List<org.w3c.dom.Element> elementList = JAXPUtils.selectAllNodes(
- document, "div");
+ List<org.w3c.dom.Element> elementList = JAXPUtils.selectAllNodes(document, "div");
elementList.addAll(JAXPUtils.selectAllNodes(document, "span"));
elementList.addAll(JAXPUtils.selectAllNodes(document, "p"));
elementList.addAll(JAXPUtils.selectAllNodes(document, "li"));
@@ -438,9 +216,7 @@
// }
return document;
} catch (Exception e) {
- log.error("Cannot parse text body. "
- + "Trying to parse as wiki document. Error message: "
- + e.getMessage());
+ log.error("Cannot parse text body. " + "Trying to parse as wiki document. Error message: " + e.getMessage());
}
return WikiContentHelper.wikiToJiveDocument(textBody);
}
@@ -485,8 +261,7 @@
}
}
- public String getCSForumsURL(String module, String op, Long c, Long f,
- Long t, Long p) {
+ public String getCSForumsURL(String module, String op, Long c, Long f, Long t, Long p) {
if ("bb".equalsIgnoreCase(module)) {
// case /index.html?module=bb
if (op == null || op.trim().length() == 0) {
@@ -500,8 +275,7 @@
// case: /index.html?module=bb&op=main&c=15
// and /index.html?module=bb&op=viewforum&f=165
- if (("main".equalsIgnoreCase(op) && c != null)
- || ("viewforum".equalsIgnoreCase(op) && f != null)) {
+ if (("main".equalsIgnoreCase(op) && c != null) || ("viewforum".equalsIgnoreCase(op) && f != null)) {
Long communityID = null;
if (("main".equalsIgnoreCase(op) && c != null)) {
@@ -517,9 +291,7 @@
}
try {
Community community = communityManager.getCommunity(communityID);
- String communityURL = JiveResourceResolver
- .getJiveObjectURL(community)
- + "?view=discussions";
+ String communityURL = JiveResourceResolver.getJiveObjectURL(community) + "?view=discussions";
return addContext(communityURL);
} catch (CommunityNotFoundException e) {
return null;
@@ -602,8 +374,7 @@
public void createInitialCommunitiesLayout() {
Properties layoutDef = new Properties();
try {
- layoutDef.load(DbNukesForumsManager.class
- .getResourceAsStream("/communities.properties"));
+ layoutDef.load(DbNukesForumsManager.class.getResourceAsStream("/communities.properties"));
} catch (IOException e) {
throw new RuntimeException("Cannot load communities layout definition", e);
}
@@ -611,13 +382,10 @@
for (CommunityDefBean communityDef : communities) {
Community projectCommunity = createCommunity(null, communityDef);
- for (CommunityDefBean communitySubDef : communityDef
- .getSubCommunityDefBeans()) {
- Community subCommunity = createCommunity(projectCommunity,
- communitySubDef);
+ for (CommunityDefBean communitySubDef : communityDef.getSubCommunityDefBeans()) {
+ Community subCommunity = createCommunity(projectCommunity, communitySubDef);
- for (CommunityDefBean communitySubSubDef : communitySubDef
- .getSubCommunityDefBeans()) {
+ for (CommunityDefBean communitySubSubDef : communitySubDef.getSubCommunityDefBeans()) {
createCommunity(subCommunity, communitySubSubDef);
}
@@ -629,24 +397,21 @@
/**
* Create community based on community definition
*
- * @param parentCommunity
- * parent community or null
+ * @param parentCommunity parent community or null
* @param communityDef
* @return created CS community
*/
- private Community createCommunity(Community parentCommunity,
- CommunityDefBean communityDef) {
+ private Community createCommunity(Community parentCommunity, CommunityDefBean communityDef) {
String communityName = stripOutSuffix(communityDef.getName());
log.info("Create community: " + communityName);
Community community;
if (parentCommunity == null) {
- community = communityManager.createCommunity(communityName, communityDef
- .getDisplayName(), communityDef.getDescription());
+ community = communityManager.createCommunity(communityName, communityDef.getDisplayName(),
+ communityDef.getDescription());
} else {
- community = communityManager.createCommunity(parentCommunity,
- communityName, communityDef.getDisplayName(), communityDef
- .getDescription());
+ community = communityManager.createCommunity(parentCommunity, communityName, communityDef.getDisplayName(),
+ communityDef.getDescription());
}
// add subproject - forums mappings
@@ -673,8 +438,7 @@
String prefix = rootPrefix + i;
if (layoutDef.getProperty(prefix + ".dname") == null) {
- log.info("No definition for '" + prefix
- + ".name'. Probably no more community definition.");
+ log.info("No definition for '" + prefix + ".name'. Probably no more community definition.");
break;
}
@@ -687,8 +451,7 @@
if (layoutDef.getProperty(subPrefix + ".dname") == null) {
break;
}
- CommunityDefBean subCommunityDef = createCommunityDef(subPrefix,
- layoutDef);
+ CommunityDefBean subCommunityDef = createCommunityDef(subPrefix, layoutDef);
int k = 1;
Set<CommunityDefBean> subSubCommunities = new LinkedHashSet<CommunityDefBean>();
@@ -697,8 +460,7 @@
if (layoutDef.getProperty(subSubPrefix + ".dname") == null) {
break;
}
- CommunityDefBean subSubCommunityDef = createCommunityDef(
- subSubPrefix, layoutDef);
+ CommunityDefBean subSubCommunityDef = createCommunityDef(subSubPrefix, layoutDef);
subSubCommunities.add(subSubCommunityDef);
k++;
@@ -718,50 +480,42 @@
return communities;
}
- private CommunityDefBean createCommunityDef(String prefix,
- Properties layoutDef) {
+ private CommunityDefBean createCommunityDef(String prefix, Properties layoutDef) {
CommunityDefBean communityDef;
String communityName = layoutDef.getProperty(prefix + ".name");
String forumID4NameStr = layoutDef.getProperty(prefix + ".forumID4Name");
if (forumID4NameStr != null && forumID4NameStr.length() > 0) {
Long forumID4Name = Long.parseLong(forumID4NameStr);
- communityDef = createCommunityDef(forumID4Name, layoutDef
- .getProperty(prefix + ".forumIDs"), layoutDef.getProperty(prefix
- + ".dname"));
+ communityDef = createCommunityDef(forumID4Name, layoutDef.getProperty(prefix + ".forumIDs"),
+ layoutDef.getProperty(prefix + ".dname"));
} else {
- communityDef = createCommunityDef(communityName, layoutDef
- .getProperty(prefix + ".forumIDs"), layoutDef.getProperty(prefix
- + ".dname"), layoutDef.getProperty(prefix + ".desc"));
+ communityDef = createCommunityDef(communityName, layoutDef.getProperty(prefix + ".forumIDs"),
+ layoutDef.getProperty(prefix + ".dname"), layoutDef.getProperty(prefix + ".desc"));
}
return communityDef;
}
- private CommunityDefBean createCommunityDef(Long forumID4Name,
- String communityForumIDsStr, String displayName) {
+ private CommunityDefBean createCommunityDef(Long forumID4Name, String communityForumIDsStr, String displayName) {
NukesForumsForumBean forumBean = nukesForumsDAO.getForumByID(forumID4Name);
- return createCommunityDef(forumBean.getName(), communityForumIDsStr,
- displayName, forumBean.getDescription());
+ return createCommunityDef(forumBean.getName(), communityForumIDsStr, displayName, forumBean.getDescription());
}
- private CommunityDefBean createCommunityDef(String communityName,
- String communityForumIDsStr, String displayName, String description) {
+ private CommunityDefBean createCommunityDef(String communityName, String communityForumIDsStr, String displayName,
+ String description) {
Set<Long> forumIds = new LinkedHashSet<Long>();
if (communityForumIDsStr != null) {
- StringTokenizer forumIdsTokenizer = new StringTokenizer(
- communityForumIDsStr, ",");
+ StringTokenizer forumIdsTokenizer = new StringTokenizer(communityForumIDsStr, ",");
while (forumIdsTokenizer.hasMoreTokens()) {
forumIds.add(Long.parseLong(forumIdsTokenizer.nextToken()));
}
}
- return new CommunityDefBean(communityName, forumIds, displayName,
- description);
+ return new CommunityDefBean(communityName, forumIds, displayName, description);
}
- public void setNukesForumsMappingDAO(
- NukesForumsMappingDAO nukesForumsMappingDAO) {
+ public void setNukesForumsMappingDAO(NukesForumsMappingDAO nukesForumsMappingDAO) {
this.nukesForumsMappingDAO = nukesForumsMappingDAO;
}
@@ -791,8 +545,7 @@
* @param defaultTopicTimeStr
* @throws ParseException
*/
- public void setDefaultTopicTimeStr(String defaultTopicTimeStr)
- throws ParseException {
+ public void setDefaultTopicTimeStr(String defaultTopicTimeStr) throws ParseException {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
defaultTopicTime = df.parse(defaultTopicTimeStr);
}
@@ -817,21 +570,19 @@
return appContext;
}
- public void setTopicMappings(
- com.jivesoftware.community.cache.Cache<Long, Long> topicMappings) {
+ public void setTopicMappings(Cache<Long, Long> topicMappings) {
this.topicMappings = topicMappings;
}
- public com.jivesoftware.community.cache.Cache<Long, Long> getTopicMappings() {
+ public Cache<Long, Long> getTopicMappings() {
return topicMappings;
}
- public void setPostMappings(
- com.jivesoftware.community.cache.Cache<Long, Long> postMappings) {
+ public void setPostMappings(Cache<Long, Long> postMappings) {
this.postMappings = postMappings;
}
- public com.jivesoftware.community.cache.Cache<Long, Long> getPostMappings() {
+ public Cache<Long, Long> getPostMappings() {
return postMappings;
}
@@ -843,10 +594,6 @@
this.watchManager = watchManager;
}
- public void setNukesUserManager(NukesUserManager nukesUserManager) {
- this.nukesUserManager = nukesUserManager;
- }
-
public void setActivityDAO(ActivityDAO activityDAO) {
this.activityDAO = activityDAO;
}
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbNukesForumsDAOImpl.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbNukesForumsDAOImpl.java 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbNukesForumsDAOImpl.java 2010-08-18 10:43:34 UTC (rev 34771)
@@ -65,8 +65,6 @@
+ "FROM phpbb_topics_watch w, nuke_users u "
+ "WHERE u.pn_uid = w.user_id AND topic_id = ?";
- private static final String SELECT_NUKES_USER_BY_USERNAME = "SELECT * FROM nuke_users WHERE pn_uname = ?";
-
private static final String SELECT_POLL_BY_TOPICID = "SELECT vote_id, topic_id, vote_text FROM phpbb_vote_desc WHERE topic_id = ?";
private static final String SELECT_POLL_OPTIONS_BY_POLLID = "SELECT vote_option_id, vote_option_text, vote_result FROM phpbb_vote_results WHERE vote_desc_id = ?";
@@ -125,11 +123,6 @@
}, forumID);
}
- public NukesUserBean getNukesUser(String username) {
- return getSimpleJdbcTemplate().queryForObject(
- SELECT_NUKES_USER_BY_USERNAME, new NukesUserBeanMapper(), username);
- }
-
public NukesPollBean loadPoll(Long topicID) {
NukesPollBean poll = getSimpleJdbcTemplate().queryForObject(
SELECT_POLL_BY_TOPICID, new NukesPollBeanMapper(), topicID);
@@ -153,16 +146,6 @@
}
/**
- * Mapper for {@link NukesUserBean} bean
- */
- class NukesUserBeanMapper implements ParameterizedRowMapper<NukesUserBean> {
- public NukesUserBean mapRow(ResultSet rs, int rowNum) throws SQLException {
- return new NukesUserBean(rs);
- }
-
- }
-
- /**
* Mapper for {@link NukesForumsPostBean} bean
*/
class NukesForumsPostBeanMapper implements
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/NukesForumsDAO.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/NukesForumsDAO.java 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/NukesForumsDAO.java 2010-08-18 10:43:34 UTC (rev 34771)
@@ -91,14 +91,6 @@
public List<String> getTopicWatchingUses(Long topicID);
/**
- * Get nukes user.
- *
- * @param username
- * @return
- */
- public NukesUserBean getNukesUser(String username);
-
- /**
* Load poll for specified topicID
*
* @param topicID
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/NukesUserBean.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/NukesUserBean.java 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/NukesUserBean.java 2010-08-18 10:43:34 UTC (rev 34771)
@@ -1,482 +0,0 @@
-package org.jboss.labs.clearspace.plugin.nfm.dao;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.jivesoftware.base.AuthToken;
-import com.jivesoftware.base.UnauthorizedException;
-import com.jivesoftware.base.User;
-import com.jivesoftware.community.Permissions;
-import com.jivesoftware.community.cache.Cacheable;
-import com.jivesoftware.community.webservices.WSUser;
-
-/**
- * Nukes User bean. Implementation taken from cs-nukes-login module.<br>
- * Nothing is changed. See org.jboss.labs.clearspace.LabsUser in
- * org.jboss.labs:cs-nukes-login:1.0-SNAPSHOT artifact
- */
-public class NukesUserBean implements User, Cacheable {
-
- private static final String CLICK_HERE_FOR_JBOSS_NEWSLETTER = "Click here for JBoss Newsletter";
-
- private static final String ADDRESS = "Address";
-
- private static final String TYPE_OF_COMPANY = "Type of Company";
-
- private static final String BIOGRAPHY = "Biography";
-
- private static final String URL = "URL";
-
- private static final String COMPANY_SIZE = "Company size";
-
- private static final String TITLE = "Title";
-
- private static final String COMPANY_NAME = "Company name";
-
- private static final String EXPERTISE = "Expertise";
-
- private static final String OCCUPATION = "Occupation";
-
- private static final String YOUR_MSN_MESSANGER = "Your MSN Messanger";
-
- private static final String YOUR_YIM_NUMBER = "Your YIM Number";
-
- private static final String YOUR_AIM_ADDRESS = "Your AIM Address";
-
- private static final String YOUR_ICQ_NUMBER = "Your ICQ Number";
-
- private static final String ALTERNATIVE_EMAIL = "Alternative Email";
-
- private static final String PHONE_NUMBER = "Phone Number";
-
- private static final String HOME_ADDRESS = "Home Address";
-
- private static final String TIME_ZONE = "Time Zone";
-
- private static final String OPT_OUT = "Click here to opt-out of ALL communication";
-
- private static final String CONTACTED = "Click here if you wish to be contacted";
-
- private final static Permissions perms = new Permissions(Permissions.NONE);;
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private Date creationDate;
- private String email;
- private long uID;
- private Date lastLoggedIn;
- private Date modifDate;
- private String name;
- private String passHash;
- private String username;
- private String firstName;
- private String lastName;
- private Map<String, String> profile;
- private boolean emailVisible;
- private static Map<String, Map<String, String>> profileDict;
-
- static {
- profileDict = new HashMap<String, Map<String, String>>();
- addDict(CLICK_HERE_FOR_JBOSS_NEWSLETTER, "0", "No", "1", "Yes");
- addDict(CONTACTED, "0", "No", "1", "Yes");
- addDict(OPT_OUT, "0", "No", "1", "Yes");
- addDict(COMPANY_SIZE, "100_999", "100-999", "_20", "-20", "21_100",
- "21-100", "1000_", "1000-");
- addDict(
- TIME_ZONE,
- "0",
- "(GMT -12:00 hours) Eniwetok, Kwajalein",
- "2",
- "(GMT -11:00 hours) Midway Island, Samoa",
- "4",
- "(GMT -10:00 hours) Hawaii",
- "6",
- "(GMT -9:00 hours) Alaska",
- "8",
- "(GMT -8:00 hours) Pacific Time (US ",
- "10",
- "(GMT -7:00 hours) Mountain Time (US ",
- "12",
- "(GMT -6:00 hours) Central Time (US ",
- "14",
- "(GMT -5:00 hours) Eastern Time (US ",
- "16",
- "(GMT -4:00 hours) Atlantic Time (Canada), Caracas, La Paz",
- "17",
- "(GMT -3:30 hours) Newfoundland",
- "18",
- "(GMT -3:00 hours) Brazil, Buenos Aires, Georgetown",
- "20",
- "(GMT -2:00 hours) Mid-Atlantic",
- "22",
- "(GMT -1:00 hours) Azores, Cape Verde Islands",
- "24",
- "(GMT) Western Europe Time, London, Lisbon, Casablanca, Monrovia",
- "26",
- "selected",
- "28",
- "(GMT +2:00 hours) EET(Eastern Europe Time), Kaliningrad, South Africa",
- "30",
- "(GMT +3:00 hours) Baghdad, Kuwait, Riyadh, Moscow, St",
- "31",
- "(GMT +3:30 hours) Tehran",
- "32",
- "(GMT +4:00 hours) Abu Dhabi, Muscat, Baku, Tbilisi",
- "33",
- "(GMT +4:30 hours) Kabul",
- "34",
- "(GMT +5:00 hours) Ekaterinburg, Islamabad, Karachi, Tashkent",
- "35",
- "(GMT +5:30 hours) Bombay, Calcutta, Madras, New Delhi",
- "36",
- "(GMT +6:00 hours) Almaty, Dhaka, Colombo",
- "38",
- "(GMT +7:00 hours) Bangkok, Hanoi, Jakarta",
- "40",
- "(GMT +8:00 hours) Beijing, Perth, Singapore, Hong Kong, Chongqing, Urumqi, Taipei",
- "42",
- "(GMT +9:00 hours) Tokyo, Seoul, Osaka, Sapporo, Yakutsk",
- "43", "(GMT +9:30 hours) Adelaide, Darwin", "44",
- "(GMT +10:00 hours) EAST(East Australian Standard)", "46",
- "(GMT +11:00 hours) Magadan, Solomon Islands, New Caledonia",
- "48",
- "(GMT +12:00 hours) Auckland, Wellington, Fiji, Kamchatka, Marshall Island");
- }
-
- private static void addDict(String field, String... fields) {
- if (fields.length % 2 == 1) {
- throw new IllegalArgumentException(
- "Wrong nomber of fields for dict (must be even): "
- + fields.length);
- }
-
- Map<String, String> oneDict = new HashMap<String, String>();
- for (int i = 0; i < fields.length; i += 2) {
- oneDict.put(fields[i], fields[i + 1]);
- }
-
- profileDict.put(field, oneDict);
- }
-
- private boolean empty(String s) {
- return s == null || s.trim().length() == 0;
- }
-
- public NukesUserBean(ResultSet rs) throws SQLException {
- creationDate = rs.getDate("pn_user_regdate");
- email = rs.getString("pn_email");
- // uID = rs.getLong("pn_uid");
- lastLoggedIn = rs.getDate("pn_last_visit");
- modifDate = creationDate;
- username = rs.getString("pn_uname");
- name = rs.getString("pn_name");
- passHash = rs.getString("pn_pass");
- firstName = rs.getString("pn_fname");
- lastName = rs.getString("pn_lname");
- emailVisible = rs.getBoolean("pn_user_viewemail");
-
- if (empty(firstName) || empty(lastName)) {
- String realName = rs.getString("pn_name");
-
- if (!empty(realName)) {
- String[] tokens = realName.split("\\s");
-
- if (empty(firstName)) {
- firstName = tokens[0];
- }
-
- if (empty(lastName)) {
- lastName = tokens[tokens.length - 1];
- }
- }
- }
-
- if (empty(name)) {
- name = firstName + " " + lastName;
- }
-
- profile = new HashMap<String, String>();
-
- profile.put(PHONE_NUMBER, rs.getString("pn_phone"));
-
- profile.put(ALTERNATIVE_EMAIL, rs.getString("pn_femail"));
- profile.put(YOUR_ICQ_NUMBER, rs.getString("pn_user_icq"));
- profile.put(YOUR_AIM_ADDRESS, rs.getString("pn_user_aim"));
- profile.put(YOUR_YIM_NUMBER, rs.getString("pn_user_yim"));
- profile.put(YOUR_MSN_MESSANGER, rs.getString("pn_user_msnm"));
- profile.put(HOME_ADDRESS, rs.getString("pn_user_from"));
-
- profile.put(OCCUPATION, rs.getString("pn_user_occ"));
- profile.put(EXPERTISE, rs.getString("pn_user_intrest"));
-
- profile.put(COMPANY_NAME, rs.getString("pn_cname"));
- profile.put(TITLE, rs.getString("pn_title"));
-
- profile.put(COMPANY_SIZE, rs.getString("pn_companysize"));
-
- // bug fix URL must be valid URL. If not it's not showed and logged exception
- profile.put(URL, normalizeURL(rs.getString("pn_url")));
-
- profile.put(BIOGRAPHY, rs.getString("pn_bio"));
-
- profile.put(TYPE_OF_COMPANY, rs.getString("pn_usertype"));
-
- profile.put(ADDRESS, "street1:" + rs.getString("pn_street")
- + ",street2:,city:" + rs.getString("pn_city") + ",state:"
- + rs.getString("pn_state") + ",country:"
- + rs.getString("pn_country") + ",zip:" + rs.getString("pn_zip")
- + ",type:WORK");
-
- profile.put(CLICK_HERE_FOR_JBOSS_NEWSLETTER, rs
- .getString("pn_newsletter"));
-
- profile.put(TIME_ZONE, rs.getString("pn_timezone_offset"));
-
- profile.put(CONTACTED, rs.getString("pn_supportcontact"));
-
- profile.put(OPT_OUT, rs.getString("pn_salescontact"));
-
- Map<String, String> profileIt = new HashMap<String, String>(profile);
-
- // remove all null values associated to keys
- for (String key : profileIt.keySet()) {
- if (profile.get(key) == null) {
- profile.remove(key);
- }
- }
-
- profile = translateProfileFields(profile);
-
- }
-
- /**
- * Normalize String representation of URL to valid URL
- * @param url
- * @return if URL is not valid then null is returned.
- */
- private String normalizeURL(String url) {
- if (url == null || url.length() < 1) {
- return url;
- }
- if (!url.startsWith("http://")) {
- url = "http://" + url;
- }
- try {
- new URL(url);
- return url;
- } catch (MalformedURLException e) {
- // not valid URL
- return null;
- }
- }
-
- private Map<String, String> translateProfileFields(
- Map<String, String> profile) {
- Map<String, String> newProfile = new HashMap<String, String>();
-
- for (String key : profile.keySet()) {
- String translatedField;
- if (profileDict.get(key) != null
- && ((translatedField = profileDict.get(key).get(
- profile.get(key))) != null)) {
-
- newProfile.put(key, translatedField);
- } else {
- newProfile.put(key, profile.get(key));
- }
- }
-
- return newProfile;
- }
-
- public Map<String, String> getProfile() {
- return profile;
- }
-
- public NukesUserBean(String username) {
- this.username = username;
- }
-
- public Date getCreationDate() {
- return creationDate;
- }
-
- public String getEmail() {
- return email;
- }
-
- public long getID() {
- return uID;
- }
-
- public Date getLastLoggedIn() {
- return lastLoggedIn;
- }
-
- public Date getModificationDate() {
- return modifDate;
- }
-
- public String getName() {
- return name;
- }
-
- public String getPassword() throws UnauthorizedException {
- return null;
- }
-
- public String getPasswordHash() throws UnauthorizedException {
- return passHash;
- }
-
- public Permissions getPermissions(AuthToken token) {
- // TODO Auto-generated method stub
- return perms;
- }
-
- public Map<String, String> getProperties() {
- // TODO Auto-generated method stub
- return new HashMap<String, String>();
- }
-
- public String getUsername() {
- return username;
- }
-
- public boolean isAuthorized(long permissionType) {
- return true;
- }
-
- public boolean isEmailVisible() {
- return emailVisible;
- }
-
- public boolean isEnabled() {
- return true;
- }
-
- public boolean isExternal() {
- return false;
- }
-
- public boolean isFederated() {
- return true;
- }
-
- public boolean isGetPasswordHashSupported() {
- return true;
- }
-
- public boolean isNameVisible() {
- return true;
- }
-
- public boolean isPropertyEditSupported() {
- return false;
- }
-
- public boolean isSetEmailSupported() {
- return false;
- }
-
- public boolean isSetEmailVisibleSupported() {
- return false;
- }
-
- public boolean isSetNameSupported() {
- return false;
- }
-
- public boolean isSetNameVisibleSupported() {
- return false;
- }
-
- public boolean isSetPasswordHashSupported() {
- return false;
- }
-
- public boolean isSetPasswordSupported() {
- return false;
- }
-
- public boolean isSetUsernameSupported() {
- return false;
- }
-
- public int getObjectType() {
- // TODO wth is it ?
- return 1;
- }
-
- public int getCachedSize() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public WSUser getWSUser() {
- WSUser u = new WSUser();
- u.setCreationDate(getCreationDate());
- u.setEmail(getEmail());
- u.setEmailVisible(false);
- u.setEnabled(true);
- u.setID(getID());
- u.setModificationDate(getModificationDate());
- u.setName(getName());
- u.setNameVisible(true);
- u.setPassword(getPasswordHash());
- u.setUsername(getUsername());
-
- return u;
- }
-
- public void setID(long id) {
- this.uID = id;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public Status getStatus() {
- return Status.registered;
- }
-
- public boolean isAnonymous() {
- return false;
- }
-
- @Override
- public Date getLastProfileUpdate() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isEmailViewable() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isNameViewable() {
- // TODO Auto-generated method stub
- return true;
- }
-
- @Override
- public boolean isVisible() {
- // TODO Auto-generated method stub
- return true;
- }
-}
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/cache-config.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/cache-config.xml 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/cache-config.xml 2010-08-18 10:43:34 UTC (rev 34771)
@@ -1,39 +0,0 @@
-<cache-config>
- <cache-mapping>
- <cache-name>Nukes Forums Topic mapping</cache-name>
- <scheme-name>default-near</scheme-name>
- <init-params>
- <init-param>
- <param-name>back-size-high</param-name>
- <param-value>131072</param-value>
- </init-param>
- <init-param>
- <param-name>back-expiry</param-name>
- <param-value>6h</param-value>
- </init-param>
- <init-param>
- <param-name>back-size-low</param-name>
- <param-value>117965</param-value>
- </init-param>
- </init-params>
- </cache-mapping>
- <cache-mapping>
- <cache-name>Nukes Forums Post mapping</cache-name>
- <scheme-name>default-near</scheme-name>
- <init-params>
- <init-param>
- <param-name>back-size-high</param-name>
- <param-value>131072</param-value>
- </init-param>
- <init-param>
- <param-name>back-expiry</param-name>
- <param-value>6h</param-value>
- </init-param>
- <init-param>
- <param-name>back-size-low</param-name>
- <param-value>117965</param-value>
- </init-param>
- </init-params>
- </cache-mapping>
-
-</cache-config>
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/plugin.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/plugin.xml 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/plugin.xml 2010-08-18 10:43:34 UTC (rev 34771)
@@ -3,8 +3,8 @@
<name>nukes-forums-migration</name>
<description>Migration tool for movement Nukes Forums to Clearspace discussions</description>
<author>JBoss Community</author>
- <version>2.0.0</version>
- <minServerVersion>4.0.0</minServerVersion>
+ <version>2.1.0</version>
+ <minServerVersion>4.5.3</minServerVersion>
<!-- Plugin class
<class>org.jboss.labs.clearspace.plugin.hfurl.HFURLPlugin</class>
@@ -12,7 +12,8 @@
<databaseKey>nukesForumsMigration</databaseKey>
<databaseVersion>1</databaseVersion>
-
+<!--
+No more needed.
<components>
<component id="admin-console">
<tab id="system">
@@ -25,5 +26,5 @@
</tab>
</component>
</components>
-
+-->
</plugin>
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/spring.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/spring.xml 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/plugin/spring.xml 2010-08-18 10:43:34 UTC (rev 34771)
@@ -37,8 +37,6 @@
<property name="topicMappings" ref="topicMappings" />
<property name="postMappings" ref="postMappings" />
- <property name="nukesUserManager" ref="nukesUserManager" />
-
<property name="activityDAO" ref="activityDAO" />
<property name="converters">
@@ -48,15 +46,6 @@
</property>
</bean>
- <bean id="nukesUserManager"
- class="org.jboss.labs.clearspace.plugin.nfm.DbNukesUserManager">
- <property name="userManager" ref="userManagerImpl" />
- <property name="profileManager" ref="profileManagerImpl" />
- <property name="profileFieldManager" ref="profileFieldManagerImpl" />
-<!-- <property name="nukesForumsDAO" ref="nukesForumsDAO" /> -->
- </bean>
-
-
<!--
Lazy init is due we not sure that admin put porta-format-lib.jar to
classpath
@@ -90,22 +79,4 @@
</property>
</bean>
- <!-- it's not used anymore.
- <bean id="nukesForumsDAO"
- class="org.jboss.labs.clearspace.plugin.nfm.dao.DbNukesForumsDAOImpl">
- <property name="dataSource" value="null"/>
- </bean>
- -->
-
- <!--
- Put these definition to jiveHome/etc/spring.xml or uncomment it and deploy a plugin
- <bean id="nukesForumsDataSource"
- class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/nukesprod" />
- <property name="username" value="nukesprod" />
- <property name="password" value="" />
- </bean>
- -->
-
</beans>
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/test/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManagerTest.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/test/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManagerTest.java 2010-08-18 08:22:02 UTC (rev 34770)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/test/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManagerTest.java 2010-08-18 10:43:34 UTC (rev 34771)
@@ -39,12 +39,11 @@
import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsPostBean;
import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsTopicBean;
import org.jboss.labs.clearspace.plugin.nfm.dao.NukesPollBean;
-import org.jboss.labs.clearspace.plugin.nfm.dao.NukesUserBean;
import org.junit.Before;
import org.junit.Test;
import org.springframework.dao.EmptyResultDataAccessException;
-import com.jivesoftware.community.cache.CoherenceCache;
+import com.jivesoftware.community.cache.CacheBean;
/**
* Test of {@link DbNukesForumsManager}
@@ -58,14 +57,17 @@
private static final String MODULE_BB = "bb";
- @SuppressWarnings("unchecked")
@Before
public void setupDbNukesForumsManagerTest() {
dbNukesForumsManager = new DbNukesForumsManager();
- dbNukesForumsManager
- .setNukesForumsMappingDAO(new DummyNukesForumsMappingDAO());
- dbNukesForumsManager.setTopicMappings(new CoherenceCache());
- dbNukesForumsManager.setPostMappings(new CoherenceCache());
+ dbNukesForumsManager.setNukesForumsMappingDAO(new DummyNukesForumsMappingDAO());
+ CacheBean<Long, Long> topicMappings = new CacheBean<Long, Long>("Topic Mappings");
+ topicMappings.init();
+ CacheBean<Long, Long> postMappings = new CacheBean<Long, Long>("Post Mappings");
+ postMappings.init();
+
+ dbNukesForumsManager.setTopicMappings(topicMappings);
+ dbNukesForumsManager.setPostMappings(postMappings);
dbNukesForumsManager.setNukesForumsDAO(new DummyNukesForumsDAO());
}
@@ -73,12 +75,12 @@
public void testStripOutSuffix() {
DbNukesForumsManager nukesForumsManager = new DbNukesForumsManager();
nukesForumsManager.setStripOutSuffix(" Users");
-
+
assertEquals("JBoss Portal", nukesForumsManager.stripOutSuffix("JBoss Portal Users"));
assertEquals("JBoss Portal", nukesForumsManager.stripOutSuffix("JBoss Portal"));
assertEquals("JBoss Users forum", nukesForumsManager.stripOutSuffix("JBoss Users forum"));
}
-
+
/**
* Test method for
* {@link org.jboss.labs.clearspace.plugin.nfm.DbNukesForumsManager#getCSForumsURL(java.lang.String, java.lang.String, java.lang.Long, java.lang.Long, java.lang.Long, java.lang.Long)}
@@ -86,28 +88,23 @@
@Test
public void testGetCSForumsURL() {
- assertEquals("/community/threads", dbNukesForumsManager.getCSForumsURL(
- MODULE_BB, null, null, null, null, null));
+ assertEquals("/community/threads", dbNukesForumsManager.getCSForumsURL(MODULE_BB, null, null, null, null, null));
// assertEquals("community/community/jbossas?view=discussions",
// dbNukesForumsManager.getCSForumsURL(MODULE_BB, "main", new Long(5),
// null, null, null));
- assertEquals("/community/thread/16549?tstart=0", dbNukesForumsManager
- .getCSForumsURL(MODULE_BB, "viewtopic", null, null, new Long(16549),
- null));
+ assertEquals("/community/thread/16549?tstart=0",
+ dbNukesForumsManager.getCSForumsURL(MODULE_BB, "viewtopic", null, null, new Long(16549), null));
- assertEquals("/community/message/18465#18465", dbNukesForumsManager
- .getCSForumsURL(MODULE_BB, "viewtopic", null, null, null, new Long(
- 18465)));
+ assertEquals("/community/message/18465#18465",
+ dbNukesForumsManager.getCSForumsURL(MODULE_BB, "viewtopic", null, null, null, new Long(18465)));
- assertEquals("/community/poll.jspa?poll=45984", dbNukesForumsManager
- .getCSForumsURL(MODULE_BB, "viewtopic", null, null, new Long(-45984),
- null));
+ assertEquals("/community/poll.jspa?poll=45984",
+ dbNukesForumsManager.getCSForumsURL(MODULE_BB, "viewtopic", null, null, new Long(-45984), null));
- assertEquals("/community/poll.jspa?poll=9425", dbNukesForumsManager
- .getCSForumsURL(MODULE_BB, "viewtopic", null, null, null, new Long(
- -9425)));
+ assertEquals("/community/poll.jspa?poll=9425",
+ dbNukesForumsManager.getCSForumsURL(MODULE_BB, "viewtopic", null, null, null, new Long(-9425)));
}
@@ -115,49 +112,39 @@
public void testLoadCommunityLayout() {
Properties layoutDef = new Properties();
try {
- layoutDef.load(DbNukesForumsManager.class
- .getResourceAsStream("/communities-test.properties"));
+ layoutDef.load(DbNukesForumsManager.class.getResourceAsStream("/communities-test.properties"));
} catch (IOException e) {
throw new RuntimeException("Cannot load communities layout definition", e);
}
- Set<CommunityDefBean> layoutSet = dbNukesForumsManager
- .loadCommunityLayout(layoutDef);
+ Set<CommunityDefBean> layoutSet = dbNukesForumsManager.loadCommunityLayout(layoutDef);
Iterator<CommunityDefBean> layoutIt = layoutSet.iterator();
CommunityDefBean jbossAS = layoutIt.next();
assertEquals("jboss-as", jbossAS.getDisplayName());
assertEquals("JBoss AS", jbossAS.getName());
assertEquals("JBoss AS Space", jbossAS.getDescription());
- assertArrayEquals(new Long[] { 1l, 2l, 3l, 4l }, jbossAS.getForumIDs()
- .toArray());
+ assertArrayEquals(new Long[] { 1l, 2l, 3l, 4l }, jbossAS.getForumIDs().toArray());
- Iterator<CommunityDefBean> jbossASSubs = jbossAS.getSubCommunityDefBeans()
- .iterator();
+ Iterator<CommunityDefBean> jbossASSubs = jbossAS.getSubCommunityDefBeans().iterator();
CommunityDefBean jbossASDev = jbossASSubs.next();
assertEquals("dev", jbossASDev.getDisplayName());
assertEquals("JBoss AS Developers", jbossASDev.getName());
assertEquals("JBoss AS Developers Space", jbossASDev.getDescription());
- assertArrayEquals(new Long[] { 5l, 6l, 7l, 8l }, jbossASDev.getForumIDs()
- .toArray());
+ assertArrayEquals(new Long[] { 5l, 6l, 7l, 8l }, jbossASDev.getForumIDs().toArray());
- Iterator<CommunityDefBean> jbossASSubSubs = jbossASDev
- .getSubCommunityDefBeans().iterator();
+ Iterator<CommunityDefBean> jbossASSubSubs = jbossASDev.getSubCommunityDefBeans().iterator();
CommunityDefBean jbossASDevSub = jbossASSubSubs.next();
assertEquals("sub", jbossASDevSub.getDisplayName());
assertEquals("JBoss AS Developers sub space", jbossASDevSub.getName());
- assertEquals("JBoss AS Developers Space sub space ...", jbossASDevSub
- .getDescription());
- assertArrayEquals(new Long[] { 30l, 40l }, jbossASDevSub.getForumIDs()
- .toArray());
+ assertEquals("JBoss AS Developers Space sub space ...", jbossASDevSub.getDescription());
+ assertArrayEquals(new Long[] { 30l, 40l }, jbossASDevSub.getForumIDs().toArray());
CommunityDefBean jbossASDevSub2 = jbossASSubSubs.next();
assertEquals("sub2", jbossASDevSub2.getDisplayName());
assertEquals("JBoss AS Developers sub2 space", jbossASDevSub2.getName());
- assertEquals("JBoss AS Developers Space sub2 space ...", jbossASDevSub2
- .getDescription());
- assertArrayEquals(new Long[] { 50l }, jbossASDevSub2.getForumIDs()
- .toArray());
+ assertEquals("JBoss AS Developers Space sub2 space ...", jbossASDevSub2.getDescription());
+ assertArrayEquals(new Long[] { 50l }, jbossASDevSub2.getForumIDs().toArray());
CommunityDefBean jbossASSub = jbossASSubs.next();
assertEquals("Another sub community", jbossASSub.getName());
@@ -170,8 +157,7 @@
assertEquals("Portal Space", portal.getDescription());
assertArrayEquals(new Long[] { 9l }, portal.getForumIDs().toArray());
- Iterator<CommunityDefBean> portalubs = portal.getSubCommunityDefBeans()
- .iterator();
+ Iterator<CommunityDefBean> portalubs = portal.getSubCommunityDefBeans().iterator();
CommunityDefBean portalDev = portalubs.next();
assertEquals("dev", portalDev.getDisplayName());
assertEquals("Portal Developers", portalDev.getName());
@@ -189,13 +175,11 @@
return null;
}
- public Long getPostMapping(Long postID)
- throws EmptyResultDataAccessException {
+ public Long getPostMapping(Long postID) throws EmptyResultDataAccessException {
return postID;
}
- public Long getTopicMapping(Long topicID)
- throws EmptyResultDataAccessException {
+ public Long getTopicMapping(Long topicID) throws EmptyResultDataAccessException {
return topicID;
}
@@ -220,8 +204,7 @@
return null;
}
- public List<NukesForumsPostBean> getAllPostsByTopicID(Long topicID,
- Long exceptPostID) {
+ public List<NukesForumsPostBean> getAllPostsByTopicID(Long topicID, Long exceptPostID) {
return null;
}
@@ -240,10 +223,6 @@
return null;
}
- public NukesUserBean getNukesUser(String username) {
- return null;
- }
-
public NukesForumsPostBean getPostByID(Long postID) {
return null;
}
More information about the jboss-svn-commits
mailing list