Search in sources :

Example 96 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project openolat by klemens.

the class ModifyCourseEvent method getCourseBaseContainer.

/**
 * the provided resourceableID must belong to a ICourse.getResourceableId(), otherwise you
 * risk to use a wrong course base container.
 * @param resourceableId
 * @return
 */
public static VFSContainer getCourseBaseContainer(Long resourceableId) {
    String relPath = "/course/" + resourceableId.longValue();
    OlatRootFolderImpl courseRootContainer = new OlatRootFolderImpl(relPath, null);
    File fBasePath = courseRootContainer.getBasefile();
    if (!fBasePath.exists())
        throw new OLATRuntimeException(PersistingCourseImpl.class, "Could not resolve course base path:" + courseRootContainer, null);
    return courseRootContainer;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) File(java.io.File)

Example 97 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project openolat by klemens.

the class XMLParser method parse.

/**
 * @param in
 * @param validateXML
 * @return parsed document
 */
public Document parse(InputStream in, boolean validateXML) {
    Document document;
    try {
        SAXReader reader = new SAXReader();
        reader.setEntityResolver(er);
        reader.setValidation(validateXML);
        document = reader.read(in, "");
        document.normalize();
    } catch (Exception e) {
        throw new OLATRuntimeException(XMLParser.class, "Exception reading XML", e);
    }
    return document;
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) SAXReader(org.dom4j.io.SAXReader) Document(org.dom4j.Document) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 98 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project openolat by klemens.

the class XStreamHelper method readObject.

/**
 * Read an object from the given leaf using the xStream object. It is
 * usefull to add field and attribute mappers to the stream.
 *
 * @param xStream
 *            The (configured) xStream.
 * @param file
 * @return
 */
public static Object readObject(XStream xStream, VFSLeaf file) {
    InputStream fis = null;
    BufferedInputStream bis = null;
    try {
        fis = file.getInputStream();
        bis = new BufferedInputStream(fis);
        return readObject(xStream, bis);
    } catch (Exception e) {
        throw new OLATRuntimeException(XStreamHelper.class, "could not read Object from file: " + file.getName(), e);
    } finally {
        try {
            if (fis != null)
                fis.close();
            if (bis != null)
                bis.close();
        } catch (Exception e) {
        // we did our best to close the inputStream
        }
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 99 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project openolat by klemens.

the class MSCourseNode method getMaxScoreConfiguration.

/**
 * @see org.olat.course.nodes.AssessableCourseNode#getMaxScoreConfiguration()
 */
@Override
public Float getMaxScoreConfiguration() {
    if (!hasScoreConfigured()) {
        throw new OLATRuntimeException(MSCourseNode.class, "getMaxScore not defined when hasScore set to false", null);
    }
    ModuleConfiguration config = getModuleConfiguration();
    Float max = (Float) config.get(CONFIG_KEY_SCORE_MAX);
    return max;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 100 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project openolat by klemens.

the class PortfolioCourseNode method getCutValueConfiguration.

@Override
public Float getCutValueConfiguration() {
    if (!hasPassedConfigured()) {
        throw new OLATRuntimeException(PortfolioCourseNode.class, "getCutValue not defined when hasPassed set to false", null);
    }
    ModuleConfiguration config = getModuleConfiguration();
    Float cut = (Float) config.get(MSCourseNode.CONFIG_KEY_PASSED_CUT_VALUE);
    return cut;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Aggregations

OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)268 IOException (java.io.IOException)104 File (java.io.File)50 ModuleConfiguration (org.olat.modules.ModuleConfiguration)26 ArrayList (java.util.ArrayList)22 AssertException (org.olat.core.logging.AssertException)22 FileOutputStream (java.io.FileOutputStream)20 OutputStream (java.io.OutputStream)20 Properties (java.util.Properties)20 FileInputStream (java.io.FileInputStream)18 HashMap (java.util.HashMap)18 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)18 QTIItemObject (org.olat.ims.qti.export.helper.QTIItemObject)18 DefaultElement (org.dom4j.tree.DefaultElement)16 Element (org.jdom.Element)16 InputStream (java.io.InputStream)14 BufferedInputStream (java.io.BufferedInputStream)12 List (java.util.List)12 Document (org.dom4j.Document)12 CPItem (org.olat.ims.cp.objects.CPItem)12