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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations