Author: fmancinelli
Date: 2007-10-30 00:50:27 +0100 (Tue, 30 Oct 2007)
New Revision: 5565
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/plugins/eclipse/XWikiEclipsePlugin.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiConnectionManager.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiConnection.java
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/DiskCacheDAO.java
Log:
XECLIPSE-30 Fixed a minor bug causing a null pointer exception in getting
cached page
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/plugins/eclipse/XWikiEclipsePlugin.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/plugins/eclipse/XWikiEclipsePlugin.java
2007-10-29 23:37:13 UTC (rev 5564)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/plugins/eclipse/XWikiEclipsePlugin.java
2007-10-29 23:50:27 UTC (rev 5565)
@@ -83,7 +83,8 @@
}
File connections = new File(getStateLocation().toFile(),
"connections.data");
-
org.xwiki.xeclipse.XWikiConnectionManager.getDefault().saveConnections(connections);
+
org.xwiki.xeclipse.XWikiConnectionManager.getDefault().saveConnections(connections);
+ org.xwiki.xeclipse.XWikiConnectionManager.getDefault().dispose();
plugin = null;
super.stop(context);
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiConnectionManager.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiConnectionManager.java
2007-10-29 23:37:13 UTC (rev 5564)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/XWikiConnectionManager.java
2007-10-29 23:50:27 UTC (rev 5565)
@@ -32,6 +32,7 @@
import org.eclipse.core.runtime.ListenerList;
import org.xwiki.xeclipse.model.IXWikiConnection;
+import org.xwiki.xeclipse.model.XWikiConnectionException;
public class XWikiConnectionManager
{
@@ -99,6 +100,16 @@
idToPasswordMapping = (Map<String, String>) ois.readObject();
ois.close();
}
+
+ public void dispose() {
+ for(IXWikiConnection xwikiConnecton : xwikiConnections) {
+ try {
+ xwikiConnecton.dispose();
+ } catch (XWikiConnectionException e) {
+ e.printStackTrace();
+ }
+ }
+ }
// /////////////////////////// Event listeners management
/////////////////////////////
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiConnection.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiConnection.java
2007-10-29 23:37:13 UTC (rev 5564)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/IXWikiConnection.java
2007-10-29 23:50:27 UTC (rev 5565)
@@ -49,7 +49,7 @@
/**
* Dispose the connection manager by releasing all the resources
associated with it. This method
- * should be called whenever the connection manager is not used anymore.
+ * should be called whenever the connection is not used anymore.
* @throws XWikiConnectionException
*/
public void dispose() throws XWikiConnectionException;
Modified:
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/DiskCacheDAO.java
===================================================================
---
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/DiskCacheDAO.java
2007-10-29 23:37:13 UTC (rev 5564)
+++
xwiki-extensions/xwiki-eclipse/trunk/plugins/org.xwiki.eclipse/src/main/java/org/xwiki/xeclipse/model/impl/DiskCacheDAO.java
2007-10-29 23:50:27 UTC (rev 5565)
@@ -25,16 +25,17 @@
{
/**
- * A class that contains all the indexes for handling the cache.
- * Objects of this class will be serialized in order to provide
persistence to the indexes.
- * This is a convenience class for storing all the indexes in a single
step.
+ * A class that contains all the indexes for handling the cache. Objects
of this class will be
+ * serialized in order to provide persistence to the indexes. This is a
convenience class for
+ * storing all the indexes in a single step.
*/
private static class IndexAggregate implements Serializable
{
private static final long serialVersionUID = 7034420710276064016L;
/**
- * A mapping that associates a page id to the file name under which
page information have been stored in the cache.
+ * A mapping that associates a page id to the file name under which
page information have
+ * been stored in the cache.
*/
private Map<String, String> pageToDataFileNameIndex;
@@ -44,7 +45,8 @@
private Map<String, Set<String>> spaceToPagesIndex;
/**
- * A mapping that associates a space id to the file name under which
space information have been stored in the cache.
+ * A mapping that associates a space id to the file name under which
space information have
+ * been stored in the cache.
*/
private Map<String, String> spaceToDataFileNameIndex;
@@ -160,7 +162,7 @@
e.printStackTrace();
}
}
-
+
/**
* @return A list of the available spaces in the cache.
* @throws XWikiDAOException
@@ -207,7 +209,7 @@
/**
* @param spaceKey The space key.
- * @return The page summaries for all the pages available in the given
space.
+ * @return The page summaries for all the pages available in the given
space.
* @throws XWikiDAOException
*/
public List<PageSummary> getPages(String spaceKey) throws XWikiDAOException
@@ -215,14 +217,17 @@
List<PageSummary> result = new ArrayList<PageSummary>();
try {
- for (String pageId :
indexAggregate.getSpaceToPagesIndex().get(spaceKey)) {
- String dataFileName =
indexAggregate.pageToDataFileNameIndex.get(pageId);
- ObjectInputStream ois =
- new ObjectInputStream(new FileInputStream(new
File(cacheDir, dataFileName)));
- Map map = (Map) ois.readObject();
- ois.close();
+ Set<String> pageIds =
indexAggregate.getSpaceToPagesIndex().get(spaceKey);
+ if (pageIds != null) {
+ for (String pageId : pageIds) {
+ String dataFileName =
indexAggregate.pageToDataFileNameIndex.get(pageId);
+ ObjectInputStream ois =
+ new ObjectInputStream(new FileInputStream(new
File(cacheDir, dataFileName)));
+ Map map = (Map) ois.readObject();
+ ois.close();
- result.add(new PageSummary(map));
+ result.add(new PageSummary(map));
+ }
}
} catch (Exception e) {
throw new XWikiDAOException(e);
@@ -241,11 +246,10 @@
Page result = null;
try {
String dataFileName =
indexAggregate.pageToDataFileNameIndex.get(pageId);
- if(dataFileName == null)
- {
+ if (dataFileName == null) {
return null;
}
-
+
ObjectInputStream ois =
new ObjectInputStream(new FileInputStream(new File(cacheDir,
dataFileName)));
Map map = (Map) ois.readObject();
@@ -306,7 +310,7 @@
return result;
}
-
+
/**
* @param pageId The page id.
* @return true if the page identified by the id is marked as dirty.
@@ -318,6 +322,7 @@
/**
* Sets the dirty state of a page.
+ *
* @param pageId The page id.
* @param dirty The new dirty state.
*/
@@ -329,25 +334,27 @@
indexAggregate.dirtyPagesIndex.remove(pageId);
}
}
-
+
/**
* @param pageId The page id.
* @return true if the page identified by the id is marked as in conflict.
- */
- public boolean isInConflict(String pageId) {
+ */
+ public boolean isInConflict(String pageId)
+ {
return indexAggregate.conflictPagesIndex.contains(pageId);
}
-
+
/**
* Sets the "in conflict" state of a page.
+ *
* @param pageId The page id.
* @param conflict The new "in conflict" state.
*/
- public void setConflict(String pageId, boolean conflict) {
- if(conflict) {
+ public void setConflict(String pageId, boolean conflict)
+ {
+ if (conflict) {
indexAggregate.conflictPagesIndex.add(pageId);
- }
- else {
+ } else {
indexAggregate.conflictPagesIndex.remove(pageId);
}
}
@@ -358,5 +365,5 @@
public Set<String> getDirtyPages()
{
return indexAggregate.getDirtyPagesIndex();
- }
+ }
}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications