use of org.olat.ims.resources.IMSEntityResolver in project OpenOLAT by OpenOLAT.
the class QTIImportProcessor method readXml.
private Document readXml(InputStream in) {
Document doc = null;
try {
XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
doc = xmlParser.parse(in, false);
return doc;
} catch (Exception e) {
return null;
}
}
use of org.olat.ims.resources.IMSEntityResolver in project OpenOLAT by OpenOLAT.
the class TestFileResource method getQTIDocument.
public static QTIDocument getQTIDocument(OLATResource resource) {
File packageDir = FileResourceManager.getInstance().unzipFileResource(resource);
File qtiFile = new File(packageDir, ImsRepositoryResolver.QTI_FILE);
try (InputStream in = new FileInputStream(qtiFile)) {
XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
Document doc = xmlParser.parse(in, true);
ParserManager parser = new ParserManager();
QTIDocument document = (QTIDocument) parser.parse(doc);
return document;
} catch (Exception e) {
log.error("Exception when parsing input QTI input stream for ", e);
return null;
}
}
use of org.olat.ims.resources.IMSEntityResolver in project OpenOLAT by OpenOLAT.
the class CPManifestTreeModel method loadDocument.
private Document loadDocument(VFSLeaf documentF) throws IOException {
InputStream in = null;
Document doc = null;
try {
in = documentF.getInputStream();
XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
doc = xmlParser.parse(in, false);
in.close();
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException("could not read and parse from file " + documentF, e);
} finally {
IOUtils.closeQuietly(in);
}
return doc;
}
use of org.olat.ims.resources.IMSEntityResolver in project openolat by klemens.
the class QTI12To21ConverterTest method loadDocument.
private QTIDocument loadDocument(String filename) {
try (InputStream in = QTI12To21ConverterTest.class.getResourceAsStream(filename)) {
XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
Document doc = xmlParser.parse(in, true);
ParserManager parser = new ParserManager();
return (QTIDocument) parser.parse(doc);
} catch (Exception e) {
log.error("Exception when parsing input QTI input stream for " + filename, e);
return null;
}
}
use of org.olat.ims.resources.IMSEntityResolver in project openolat by klemens.
the class ScormCPManifestTreeModel method loadDocument.
private Document loadDocument(File documentF) {
FileInputStream in = null;
BufferedInputStream bis = null;
Document doc = null;
try {
in = new FileInputStream(documentF);
bis = new BufferedInputStream(in);
XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
doc = xmlParser.parse(bis, false);
} catch (IOException e) {
throw new OLATRuntimeException(ScormCPManifestTreeModel.class, "could not read and parse from file " + documentF.getAbsolutePath(), e);
} finally {
try {
if (in != null)
in.close();
if (bis != null)
bis.close();
} catch (Exception e) {
// we did our best to close the inputStream
}
}
return doc;
}
Aggregations