use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class FileResourceManager method getFileResource.
/**
* @param res
* @return Get resourceable as file.
*/
private File getFileResource(OLATResourceable res, String resourceFolderName) {
FileResource fr = getAsGenericFileResource(res);
File f = getFile(fr, resourceFolderName);
if (f == null) {
// folder not existing or no file in it
throw new OLATRuntimeException(FileResourceManager.class, "could not getFileResource for OLATResourceable " + res.getResourceableId() + ":" + res.getResourceableTypeName(), null);
}
return f;
}
use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class ParserManager method parse.
/**
* @see org.olat.ims.qti.editor.beecom.parser.IParser#parse(org.dom4j.Element)
*/
public Object parse(Element element) {
try {
if (element == null)
return null;
String name = element.getName();
String parserClassName = null;
String tmpName = parserMap.get(name);
if (tmpName == null) {
parserClassName = parserMap.get(PARSER_DEFAULT);
} else {
parserClassName = tmpName;
}
if (log.isDebug()) {
log.debug("ELEMENTNAME:" + name + "PARSERNAME" + parserClassName);
}
Class<?> parserClass = this.getClass().getClassLoader().loadClass(parserClassName);
IParser parser = (IParser) parserClass.newInstance();
return parser.parse(element);
} catch (ClassNotFoundException e) {
throw new OLATRuntimeException(this.getClass(), "Class not found in QTI editor", e);
} catch (InstantiationException e) {
throw new OLATRuntimeException(this.getClass(), "Instatiation problem in QTI editor", e);
} catch (IllegalAccessException e) {
throw new OLATRuntimeException(this.getClass(), "Illegal Access in QTI editor", e);
}
}
use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class ForumNodeForumCallback method loadForum.
private Forum loadForum(CourseEnvironment courseEnv, Property prop) {
final ForumManager fom = CoreSpringFactory.getImpl(ForumManager.class);
Long forumKey = prop.getLongValue();
Forum forum = fom.loadForum(forumKey);
if (forum == null) {
throw new OLATRuntimeException(FOCourseNode.class, "Tried to load forum with key " + forumKey.longValue() + " in course " + courseEnv.getCourseResourceableId() + " for node " + getIdent() + " as defined in course node property but forum manager could not load forum.", null);
}
return forum;
}
use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class QTI21ServiceImpl method loadFilteredStateDocument.
private Document loadFilteredStateDocument(File sessionFile) {
try (InputStream in = new FileInputStream(sessionFile)) {
String xmlContent = IOUtils.toString(in, "UTF-8");
String filteredContent = FilterFactory.getXMLValidEntityFilter().filter(xmlContent);
DocumentBuilder documentBuilder = XmlFactories.newDocumentBuilder();
return documentBuilder.parse(new InputSource(new StringReader(filteredContent)));
} catch (final Exception e) {
throw new OLATRuntimeException("Could not parse serialized state XML. This is an internal error as we currently don't expose this data to clients", e);
}
}
use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method checkEssay.
private boolean checkEssay(RepositoryEntry testEntry) {
if (qtiEssayMap.containsKey(testEntry.getKey())) {
return qtiEssayMap.get(testEntry.getKey()).booleanValue();
}
TestFileResource fr = new TestFileResource();
fr.overrideResourceableId(testEntry.getOlatResource().getResourceableId());
TransientIdentity pseudoIdentity = new TransientIdentity();
pseudoIdentity.setName("transient");
Translator translator = Util.createPackageTranslator(QTIModule.class, Locale.ENGLISH);
try {
QTIEditorPackage qtiPackage = new QTIEditorPackageImpl(pseudoIdentity, fr, null, translator);
if (qtiPackage.getQTIDocument() != null && qtiPackage.getQTIDocument().getAssessment() != null) {
Assessment ass = qtiPackage.getQTIDocument().getAssessment();
// Sections with their Items
List<Section> sections = ass.getSections();
for (Section section : sections) {
List<Item> items = section.getItems();
for (Item item : items) {
String ident = item.getIdent();
if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
qtiEssayMap.put(testEntry.getKey(), Boolean.TRUE);
return true;
}
}
}
}
} catch (OLATRuntimeException e) {
log.warn("QTI without content in repository entry: " + testEntry.getKey(), e);
}
qtiEssayMap.put(testEntry.getKey(), Boolean.FALSE);
return false;
}
Aggregations