From: Xuan B. <med...@us...> - 2007-04-17 05:04:34
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29252/src/org/tm4j/topicmap/memory Modified Files: TopicImpl.java TopicMapImpl.java TopicMapObjectImpl.java Log Message: Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. Index: TopicImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/TopicImpl.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** TopicImpl.java 7 Mar 2006 15:36:35 -0000 1.72 --- TopicImpl.java 17 Apr 2007 05:04:33 -0000 1.73 *************** *** 1027,1033 **** --- 1027,1056 ---- */ public Collection getMergedTopics() { + assert checkMergedTopics(); + return m_mergedTopics == null ? Collections.EMPTY_LIST : Collections.unmodifiableCollection(m_mergedTopics); } + + protected boolean checkMergedTopics() { + if (m_mergedTopics!=null) { + try { + for (TopicImpl topic : (ArrayList<TopicImpl>) m_mergedTopics) { + if (!topic.checkNotDestroyed()) { + return false; + } + } + } catch (AssertionError e) { + m_log.error("While checking "+this+": ",e); + throw e; + } + } + + return true; + } + + protected boolean checkNotDestroyed() { + return super.checkNotDestroyed(); + } /** *************** *** 1107,1110 **** --- 1130,1140 ---- } + protected void removeMergedTopic(Topic mergedTopic) { + assert m_mergedTopics!=null; + boolean success = m_mergedTopics.remove(mergedTopic); + + assert success; + } + private void staticMerge(Topic merged) throws MergedTopicSubjectClashException { *************** *** 1545,1548 **** --- 1575,1596 ---- try { + /* XB: + + It may be that + (1) this topic is either a base topic serving for other topics or + (2) that this topic is a merged topic having a base topic. + + In such cases, this topic needs to be detached from the other topics properly. + + */ + + if (!staticallyMerged()) { + if (m_baseTopic!=null) { // We are a slave topic. We just need to sign off from our base topic. + ((TopicImpl) m_baseTopic).removeMergedTopic(this); + } else if ((m_mergedTopics!=null)&&!m_mergedTopics.isEmpty()) { // We are a base topic with at least one slave. + throw new UnsupportedOperationException(); + } + } + // If we get here, it is OK to destroy this Topic. // Remove all types *************** *** 1586,1589 **** --- 1634,1639 ---- protected void _destroy() { + // m_log.warn("Destroying "+this+".", new Exception()); + m_subject = null; *************** *** 1621,1624 **** --- 1671,1677 ---- m_baseTopic = null; + + + super._destroy(); } *************** *** 1646,1649 **** --- 1699,1706 ---- } } + + public String toString() { + return "TopicImpl[m_subjectIdentifiers="+m_subjectIdentifiers+"]"+super.toString(); + } } *************** *** 1651,1657 **** /* * $Log$ ! * Revision 1.72 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.71 2004/12/08 10:50:57 kal_ahmed --- 1708,1717 ---- /* * $Log$ ! * Revision 1.73 2007/04/17 05:04:33 mediumnet ! * Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. ! * ! * Revision 1.72 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.71 2004/12/08 10:50:57 kal_ahmed Index: TopicMapObjectImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/TopicMapObjectImpl.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** TopicMapObjectImpl.java 7 Mar 2006 15:36:35 -0000 1.37 --- TopicMapObjectImpl.java 17 Apr 2007 05:04:33 -0000 1.38 *************** *** 172,175 **** --- 172,176 ---- public Set getSourceLocators() { + assert m_sourceLocators!=null : toString()+": trying to access m_sourceLocators while apparently already destroyed."; return Collections.unmodifiableSet(m_sourceLocators); } *************** *** 489,492 **** --- 490,499 ---- } + protected boolean checkNotDestroyed() { + assert m_sourceLocators!=null : toString()+" already destroyed."; + + return m_sourceLocators!=null; + } + protected void removeChangeListeners() { if (m_namedPropertyListeners != null) { *************** *** 510,513 **** --- 517,528 ---- return other.getTopicMap().equals(getTopicMap()); } + + public String toString() { + if (m_topicMap!=this) { + return "TopicMapObjectImpl[m_sourceLocators="+m_sourceLocators+",m_topicMap="+m_topicMap+"]"+super.toString(); + } else { + return "TopicMapObjectImpl[m_sourceLocators="+m_sourceLocators+"]"+super.toString(); + } + } } *************** *** 515,521 **** /* * $Log$ ! * Revision 1.37 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.36 2004/04/22 20:45:56 kal_ahmed --- 530,539 ---- /* * $Log$ ! * Revision 1.38 2007/04/17 05:04:33 mediumnet ! * Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. ! * ! * Revision 1.37 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.36 2004/04/22 20:45:56 kal_ahmed Index: TopicMapImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/TopicMapImpl.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** TopicMapImpl.java 7 Mar 2006 15:36:35 -0000 1.72 --- TopicMapImpl.java 17 Apr 2007 05:04:33 -0000 1.73 *************** *** 1383,1386 **** --- 1383,1389 ---- } + public String toString() { + return "TopicMapImpl[m_topics.size()="+m_topics.size()+"]"; + } } *************** *** 1388,1394 **** /* * $Log$ ! * Revision 1.72 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.71 2004/09/10 20:51:52 kal_ahmed --- 1391,1400 ---- /* * $Log$ ! * Revision 1.73 2007/04/17 05:04:33 mediumnet ! * Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. ! * ! * Revision 1.72 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.71 2004/09/10 20:51:52 kal_ahmed |