use of org.olat.core.util.coordinate.LockResult in project OpenOLAT by OpenOLAT.
the class IQManager method createIQDisplayController.
/**
* IMS QTI Display Controller from within course -> moduleConfiguration
*
* concurrent access check needed -> Editor may save (commit changes) while displaying reads old/new data mix (files and xml structure)
*/
public Controller createIQDisplayController(ModuleConfiguration moduleConfiguration, IQSecurityCallback secCallback, UserRequest ureq, WindowControl wControl, long courseResId, String courseNodeIdent, NavigatorDelegate delegate) {
// two cases:
// -- VERY RARE CASE -- 1) qti is open in an editor session right now on the screen (or session on the way to timeout)
// -- 99% of cases -- 2) qti is ready to be run as test/survey
String repositorySoftkey = (String) moduleConfiguration.get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftkey, false);
if (re == null) {
log.error("The test repository entry with this soft key could not be found: " + repositorySoftkey);
Translator translator = Util.createPackageTranslator(this.getClass(), ureq.getLocale());
String title = translator.translate("error.test.deleted.title");
String msg = translator.translate("error.test.deleted.msg");
return MessageUIFactory.createInfoMessage(ureq, wControl, title, msg);
} else if (CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(re.getOlatResource(), null)) {
Translator translator = Util.createPackageTranslator(this.getClass(), ureq.getLocale());
// so this resource is locked, let's find out who locked it
LockResult lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(re.getOlatResource(), ureq.getIdentity(), null);
String fullName = userManager.getUserDisplayName(lockResult.getOwner());
return MessageUIFactory.createInfoMessage(ureq, wControl, translator.translate("status.currently.locked.title"), translator.translate("status.currently.locked", new String[] { fullName }));
} else {
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(re, OlatResourceableType.iq));
return new IQDisplayController(moduleConfiguration, secCallback, ureq, wControl, courseResId, courseNodeIdent, delegate);
}
}
use of org.olat.core.util.coordinate.LockResult in project OpenOLAT by OpenOLAT.
the class IQManager method createIQDisplayController.
/**
* IMS QTI Display Controller used for IMS course node run view, or for the direct launching from learning resources.
*
* concurrent access check needed -> Editor may save (commit changes) while displaying reads old/new data mix (files and xml structure)
*
* @param res
* @param resolver
* @param type
* @param secCallback
* @param ureq
* @param wControl
* @return
*/
public MainLayoutController createIQDisplayController(OLATResourceable res, Resolver resolver, String type, IQSecurityCallback secCallback, UserRequest ureq, WindowControl wControl) {
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(res, OlatResourceableType.iq));
// -- 99% of cases -- 2) qti is ready to be run as test/survey
if (CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(res, null)) {
LockResult lockEntry = CoordinatorManager.getInstance().getCoordinator().getLocker().aquirePersistentLock(res, ureq.getIdentity(), null);
String fullName = userManager.getUserDisplayName(lockEntry.getOwner());
GenericMainController glc = createLockedMessageController(ureq, wControl, fullName);
return glc;
} else {
Controller controller = new IQDisplayController(resolver, type, secCallback, ureq, wControl);
// fxdiff BAKS-7 Resume function
OLATResourceableListeningWrapperController dwc = new OLATResourceableListeningWrapperController(ureq, wControl, res, controller, null, ureq.getIdentity());
return dwc;
}
}
use of org.olat.core.util.coordinate.LockResult in project openolat by klemens.
the class IQManager method createIQDisplayController.
/**
* IMS QTI Display Controller used for IMS course node run view, or for the direct launching from learning resources.
*
* concurrent access check needed -> Editor may save (commit changes) while displaying reads old/new data mix (files and xml structure)
*
* @param res
* @param resolver
* @param type
* @param secCallback
* @param ureq
* @param wControl
* @return
*/
public MainLayoutController createIQDisplayController(OLATResourceable res, Resolver resolver, String type, IQSecurityCallback secCallback, UserRequest ureq, WindowControl wControl) {
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(res, OlatResourceableType.iq));
// -- 99% of cases -- 2) qti is ready to be run as test/survey
if (CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(res, null)) {
LockResult lockEntry = CoordinatorManager.getInstance().getCoordinator().getLocker().aquirePersistentLock(res, ureq.getIdentity(), null);
String fullName = userManager.getUserDisplayName(lockEntry.getOwner());
GenericMainController glc = createLockedMessageController(ureq, wControl, fullName);
return glc;
} else {
Controller controller = new IQDisplayController(resolver, type, secCallback, ureq, wControl);
// fxdiff BAKS-7 Resume function
OLATResourceableListeningWrapperController dwc = new OLATResourceableListeningWrapperController(ureq, wControl, res, controller, null, ureq.getIdentity());
return dwc;
}
}
use of org.olat.core.util.coordinate.LockResult in project openolat by klemens.
the class IQManager method createIQDisplayController.
/**
* IMS QTI Display Controller from within course -> moduleConfiguration
*
* concurrent access check needed -> Editor may save (commit changes) while displaying reads old/new data mix (files and xml structure)
*/
public Controller createIQDisplayController(ModuleConfiguration moduleConfiguration, IQSecurityCallback secCallback, UserRequest ureq, WindowControl wControl, long courseResId, String courseNodeIdent, NavigatorDelegate delegate) {
// two cases:
// -- VERY RARE CASE -- 1) qti is open in an editor session right now on the screen (or session on the way to timeout)
// -- 99% of cases -- 2) qti is ready to be run as test/survey
String repositorySoftkey = (String) moduleConfiguration.get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftkey, false);
if (re == null) {
log.error("The test repository entry with this soft key could not be found: " + repositorySoftkey);
Translator translator = Util.createPackageTranslator(this.getClass(), ureq.getLocale());
String title = translator.translate("error.test.deleted.title");
String msg = translator.translate("error.test.deleted.msg");
return MessageUIFactory.createInfoMessage(ureq, wControl, title, msg);
} else if (CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(re.getOlatResource(), null)) {
Translator translator = Util.createPackageTranslator(this.getClass(), ureq.getLocale());
// so this resource is locked, let's find out who locked it
LockResult lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(re.getOlatResource(), ureq.getIdentity(), null);
String fullName = userManager.getUserDisplayName(lockResult.getOwner());
return MessageUIFactory.createInfoMessage(ureq, wControl, translator.translate("status.currently.locked.title"), translator.translate("status.currently.locked", new String[] { fullName }));
} else {
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(re, OlatResourceableType.iq));
return new IQDisplayController(moduleConfiguration, secCallback, ureq, wControl, courseResId, courseNodeIdent, delegate);
}
}
use of org.olat.core.util.coordinate.LockResult in project openolat by klemens.
the class CatalogWebService method addOwner.
/**
* Add an owner of the local sub tree
* @response.representation.200.qname {http://www.example.com}userVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The catalog entry
* @response.representation.200.example {@link org.olat.user.restapi.Examples#SAMPLE_USERVOes}
* @response.representation.401.doc Not authorized
* @response.representation.404.doc The path could not be resolved to a valid catalog entry
* @param path The path
* @param identityKey The id of the user
* @param httpRquest The HTTP request
* @return The response
*/
@PUT
@Path("{path:.*}/owners/{identityKey}")
public Response addOwner(@PathParam("path") List<PathSegment> path, @PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest) {
Long key = getCatalogEntryKeyFromPath(path);
if (key == null) {
return Response.serverError().status(Status.NOT_ACCEPTABLE).build();
}
CatalogEntry ce = catalogManager.loadCatalogEntry(key);
if (ce == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
if (!isAuthor(httpRequest) && !canAdminSubTree(ce, httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
BaseSecurity securityManager = BaseSecurityManager.getInstance();
Identity identity = securityManager.loadIdentityByKey(identityKey, false);
if (identity == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
Identity id = getUserRequest(httpRequest).getIdentity();
LockResult lock = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(lockRes, id, LOCK_TOKEN);
if (!lock.isSuccess()) {
return getLockedResponse(lock, httpRequest);
}
try {
SecurityGroup sg = ce.getOwnerGroup();
if (sg == null) {
ce.setOwnerGroup(securityManager.createAndPersistSecurityGroup());
DBFactory.getInstance().intermediateCommit();
}
securityManager.addIdentityToSecurityGroup(identity, ce.getOwnerGroup());
} catch (Exception e) {
throw new WebApplicationException(e);
} finally {
CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(lock);
}
return Response.ok().build();
}
Aggregations