[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Problems reading instances serialized with an old package

Ben,

If you call getResource(uri, false) a second time (like what you see in the generated editor) you should find the resource there with whatever content sit was able to produce.


Ben wrote:
Though the reading does throw an exception, should not the objects in the resource still be populated with the information?


File file = new File(args[i]);
URI uri = file.isFile() ? URI.createFileURI(file.getAbsolutePath()): URI.createURI(args[0]);
Resource resource = null;
try {
resource = resourceSet.getResource(uri, true);
} catch (RuntimeException exception) {
exception.printStackTrace();


// An error occurred:
// org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with
// uri 'http://www.acme.com/XYZ3.2' not found.
for (EObject eObject : resource.getContents()) {
Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eObject);
if (diagnostic.getSeverity() != Diagnostic.OK) {
printDiagnostic(diagnostic, "");
}
}
}