Search in sources :

Example 86 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class NodeExportVisitor method load.

/**
 * Load the course from disk/database, load the run structure from xml file etc.
 */
void load() {
    /*
		 * remember that loading of the courseConfiguration is already done within
		 * the constructor !
		 */
    Object obj;
    obj = readObject(RUNSTRUCTURE_XML);
    if (!(obj instanceof Structure))
        throw new AssertException("Error reading course run structure.");
    runStructure = (Structure) obj;
    initHasAssessableNodes();
    obj = readObject(EDITORTREEMODEL_XML);
    if (!(obj instanceof CourseEditorTreeModel))
        throw new AssertException("Error reading course editor tree model.");
    editorTreeModel = (CourseEditorTreeModel) obj;
}
Also used : AssertException(org.olat.core.logging.AssertException) CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel)

Example 87 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class LocalFolderImpl method getItems.

/**
 * @see org.olat.core.util.vfs.VFSContainer#getItems(org.olat.core.util.vfs.filters.VFSItemFilter)
 */
@Override
public List<VFSItem> getItems(VFSItemFilter filter) {
    File aFolder = getBasefile();
    if (!aFolder.isDirectory()) {
        throw new AssertException("basefile is not a directory: " + aFolder.getAbsolutePath());
    }
    File[] children = aFolder.listFiles();
    if (children == null) {
        children = new File[0];
    }
    int len = children.length;
    List<VFSItem> res = new ArrayList<VFSItem>(len);
    for (int i = 0; i < len; i++) {
        File af = children[i];
        VFSItem item;
        if (af.isDirectory()) {
            LocalFolderImpl folderItem = new LocalFolderImpl(af, this);
            folderItem.setDefaultItemFilter(defaultFilter);
            item = folderItem;
        } else {
            item = new LocalFileImpl(af, this);
        }
        if (defaultFilter == null) {
            if (filter == null)
                res.add(item);
            else if (filter.accept(item))
                res.add(item);
        } else if (defaultFilter.accept(item)) {
            if (filter == null)
                res.add(item);
            else if (filter.accept(item))
                res.add(item);
        }
    }
    return res;
}
Also used : AssertException(org.olat.core.logging.AssertException) ArrayList(java.util.ArrayList) File(java.io.File)

Example 88 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class ClusterSyncer method doInSync.

/**
 * @see org.olat.core.util.coordinate.Syncer#doInSync(org.olat.core.id.OLATResourceable, org.olat.core.util.coordinate.SyncerCallback)
 */
public <T> T doInSync(OLATResourceable ores, SyncerCallback<T> callback) {
    // Store ores-object for assertAlreadyDoInSyncFor(ores)
    getData().setSyncObject(ores);
    String asset = OresHelper.createStringRepresenting(ores);
    // 1. sync on vm (performance and net bandwith reason, and also for a fair per-node handling of db request)
    // cluster:::: measure throughput with/without this sync
    // : maybe also measure if with a n-Semaphore (at most n concurrent accesses) throughput incs or decs
    long start = 0;
    boolean isDebug = log.isDebug();
    if (isDebug)
        start = System.currentTimeMillis();
    T res;
    Object syncObj = DerivedStringSyncer.getInstance().getSynchLockFor(ores);
    synchronized (syncObj) {
        // cluster_ok is per vm only. this synchronized is needed for multi-core processors to handle
        // memory-flushing from registers correctly. without this synchronized you could have different
        // states of (instance-/static-)fields in different cores
        getData().incrementAndCheckNestedLevelCounter();
        // until the transaction is committed or rollbacked
        try {
            getPessimisticLockManager().findOrPersistPLock(asset);
            // now execute the task, which may or may not contain further db queries.
            res = callback.execute();
        } finally {
            getData().decrementNestedLevelCounter();
        }
        // clear the thread local
        if (getData().getNestedLevel() == 0) {
            data.remove();
        }
        // we used to not do a commit here but delay that to the end of the dispatching-process. the comment
        // was: "the lock will be released after calling commit at the end of dispatching-process
        // needed postcondition after the servlet has finished the request: a commit or rollback on the db to release the lock.
        // otherwise the database will throw a "lock wait timeout exceeded" message after some time and thus release the lock."
        // but realizing that this can a) cause long locking phases and b) deadlocks between VMs
        // we decided to do a commit here and work with its consequence which is that everything that happened
        // prior to the doInSync call is also committed. This though corresponds to the OLAT 6.0.x model and
        // was acceptable there as well.
        dbInstance.commit();
    }
    if (isDebug) {
        long stop = System.currentTimeMillis();
        if (stop - start > executionTimeThreshold) {
            log.warn("execution time exceeded limit of " + executionTimeThreshold + ": " + (stop - start), new AssertException("generate stacktrace"));
        }
    }
    return res;
}
Also used : AssertException(org.olat.core.logging.AssertException)

Example 89 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class WimbaClassroomProvider method setPreviewMode.

public boolean setPreviewMode(String roomId, boolean enabled, boolean isRecording) {
    if (!loginAdmin())
        throw new AssertException("Cannot login to Wimba Classroom. Please check module configuration and Wimba Classroom connectivity");
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("function", "modifyClass");
    parameters.put("target", isRecording ? roomId : PREFIX + roomId);
    parameters.put("preview", param(enabled));
    String raw = sendRequest(parameters);
    WimbaResponse response = getResponseDocument(raw);
    boolean success = evaluateOk(response);
    if (!success)
        handleError(response.getStatus(), null);
    return success;
}
Also used : AssertException(org.olat.core.logging.AssertException) HashMap(java.util.HashMap)

Example 90 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class AdobeConnectProvider method getScoIdFor.

private String getScoIdFor(String roomId) {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("action", "sco-search-by-field");
    parameters.put("query", PREFIX + roomId);
    parameters.put("filter-type", "meeting");
    Document responseDoc = getResponseDocument(sendRequest(parameters));
    if (!evaluateOk(responseDoc))
        return null;
    Object result = evaluate(responseDoc, "//sco/url-path[text()='/" + PREFIX + roomId + "/']", XPathConstants.NODESET);
    if (result == null)
        return null;
    NodeList nodes = (NodeList) result;
    if (nodes.getLength() == 1) {
        String scoId = evaluate(responseDoc, "//sco[1]/attribute::sco-id");
        return scoId;
    } else if (nodes.getLength() > 1)
        throw new AssertException("More than one Adobe Connect room found for one course node!");
    else
        return null;
}
Also used : AssertException(org.olat.core.logging.AssertException) HashMap(java.util.HashMap) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document)

Aggregations

AssertException (org.olat.core.logging.AssertException)364 IOException (java.io.IOException)38 File (java.io.File)28 Identity (org.olat.core.id.Identity)28 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)24 Controller (org.olat.core.gui.control.Controller)22 OLATResourceable (org.olat.core.id.OLATResourceable)22 RepositoryEntry (org.olat.repository.RepositoryEntry)22 WindowControl (org.olat.core.gui.control.WindowControl)20 UnsupportedEncodingException (java.io.UnsupportedEncodingException)18 JSONException (org.json.JSONException)18 BusinessGroup (org.olat.group.BusinessGroup)18 JSONObject (org.json.JSONObject)16 UserRequest (org.olat.core.gui.UserRequest)16 VFSContainer (org.olat.core.util.vfs.VFSContainer)16 VFSItem (org.olat.core.util.vfs.VFSItem)16 Date (java.util.Date)14 Properties (java.util.Properties)14 Property (org.olat.properties.Property)14