Skip to content
Snippets Groups Projects
Commit f9f16ae7 authored by srosse's avatar srosse
Browse files

OO-320: add a giant lock on load/save operation in ScoDocument

parent ddc3324c
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,8 @@ import java.util.Vector; ...@@ -34,6 +34,8 @@ import java.util.Vector;
import org.jdom.Document; import org.jdom.Document;
import org.jdom.Element; import org.jdom.Element;
import org.olat.core.logging.OLATRuntimeException; import org.olat.core.logging.OLATRuntimeException;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.modules.scorm.ISettingsHandler; import org.olat.modules.scorm.ISettingsHandler;
import uk.ac.reload.jdom.XMLDocument; import uk.ac.reload.jdom.XMLDocument;
...@@ -47,6 +49,8 @@ import uk.ac.reload.jdom.XMLDocument; ...@@ -47,6 +49,8 @@ import uk.ac.reload.jdom.XMLDocument;
* @author Paul Sharples * @author Paul Sharples
*/ */
public class ScoDocument extends XMLDocument { public class ScoDocument extends XMLDocument {
private OLog log = Tracing.createLoggerFor(ScoDocument.class);
// var used to flag if the sco was "failed" // var used to flag if the sco was "failed"
private boolean isFailed = false; private boolean isFailed = false;
...@@ -120,8 +124,10 @@ public class ScoDocument extends XMLDocument { ...@@ -120,8 +124,10 @@ public class ScoDocument extends XMLDocument {
// Make sure its there // Make sure its there
if (pathToNavFile.exists()) { if (pathToNavFile.exists()) {
try { try {
super.loadDocument(pathToNavFile); synchronized(ScoDocument.class) {
super.loadDocument(pathToNavFile);
}
Element root = getDocument().getRootElement(); Element root = getDocument().getRootElement();
// set these now, so they are easy to get to when we need them later. // set these now, so they are easy to get to when we need them later.
...@@ -146,12 +152,29 @@ public class ScoDocument extends XMLDocument { ...@@ -146,12 +152,29 @@ public class ScoDocument extends XMLDocument {
isFailed = false; isFailed = false;
} }
} catch (Exception ex) { } catch (Exception ex) {
log.info("Error loading: " + pathToNavFile + " :: " + this);
throw new OLATRuntimeException(this.getClass(), "error: could not load sco model for " + scoID, ex); throw new OLATRuntimeException(this.getClass(), "error: could not load sco model for " + scoID, ex);
} }
} else { } else {
throw new OLATRuntimeException(this.getClass(), "error: could not find sco model for " + scoID, null); throw new OLATRuntimeException(this.getClass(), "error: could not find sco model for " + scoID, null);
} }
} }
@Override
public void saveAsDocument(File file) throws IOException {
synchronized(ScoDocument.class) {
super.saveAsDocument(file);
}
}
@Override
public void saveDocument() throws IOException {
synchronized(ScoDocument.class) {
super.saveDocument();
}
}
/** /**
* getScoModel() - This method searches the CMI xml file that was created when * getScoModel() - This method searches the CMI xml file that was created when
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment