提交 4e459385 编写于 作者: E Eduardo Ramos

Fix #1691 v0.9.1 unable to read v0.9 gephi file

上级 5b69bfb8
......@@ -67,6 +67,8 @@ public class GraphPersistenceProvider implements WorkspaceBytesPersistenceProvid
}
}
private static final int GRAPHSTORE_SERIALIZATION_GRAPHMODEL_CONFIG_ID = 205;
@Override
public void readBytes(DataInputStream stream, Workspace workspace) {
GraphModel model = workspace.getLookup().lookup(GraphModel.class);
......@@ -74,7 +76,18 @@ public class GraphPersistenceProvider implements WorkspaceBytesPersistenceProvid
throw new IllegalStateException("The graphModel wasn't null");
}
try {
model = GraphModel.Serialization.read(stream);
//Detect if the serialized graphstore declares its own version:
stream.mark(1);
int firstFieldType = stream.readUnsignedByte();
stream.reset();
if (firstFieldType == GRAPHSTORE_SERIALIZATION_GRAPHMODEL_CONFIG_ID) {
//Old graphstore, from Gephi 0.9.0
model = GraphModel.Serialization.readWithoutVersionHeader(stream, 0.0f /* no version, first was 0.4*/);//Previous to version header existing at all
} else {
model = GraphModel.Serialization.read(stream);
}
workspace.add(model);
} catch (IOException ex) {
throw new RuntimeException(ex);
......
Manifest-Version: 1.0
OpenIDE-Module-Localizing-Bundle: org/gephi/graph/api/Bundle.properties
AutoUpdate-Essential-Module: true
OpenIDE-Module-Specification-Version: 0.9.1.2
OpenIDE-Module-Specification-Version: 0.9.1.3
OpenIDE-Module-Display-Category: Gephi Core
OpenIDE-Module-Name: Graph API
......@@ -41,6 +41,7 @@
*/
package org.gephi.project.io;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.InputStream;
......@@ -321,7 +322,7 @@ public class LoadTask implements LongTask, Runnable {
InputStream is = null;
DataInputStream stream = null;
try {
is = zipFile.getInputStream(entry);
is = new BufferedInputStream(zipFile.getInputStream(entry));
stream = new DataInputStream(is);
persistenceProvider.readBytes(stream, workspace);
} finally {
......
......@@ -134,7 +134,7 @@
<netbeans.version>RELEASE81</netbeans.version>
<!-- Graphstore version -->
<graphstore.version>0.5.5</graphstore.version>
<graphstore.version>0.5.7</graphstore.version>
<!-- Localization ZIP version, from 'http://netbeans.org/project_downloads/nblocalization' -->
<gephi.platform.localization.version>1.1-NB80</gephi.platform.localization.version>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册