use of org.olat.core.id.IdentityEnvironment in project openolat by klemens.
the class UserCalendarWebService method getCalendars.
private void getCalendars(CalendarVisitor calVisitor, UserRequest ureq) {
Roles roles = ureq.getUserSession().getRoles();
Identity retrievedUser = ureq.getIdentity();
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (calendarModule.isEnabled()) {
if (calendarModule.isEnablePersonalCalendar()) {
KalendarRenderWrapper personalWrapper = getPersonalCalendar(ureq.getIdentity());
calVisitor.visit(personalWrapper);
}
if (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) {
RepositoryManager rm = RepositoryManager.getInstance();
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
SearchRepositoryEntryParameters repoParams = new SearchRepositoryEntryParameters(retrievedUser, roles, "CourseModule");
repoParams.setOnlyExplicitMember(true);
repoParams.setIdentity(retrievedUser);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(retrievedUser);
ienv.setRoles(roles);
List<RepositoryEntry> entries = rm.genericANDQueryWithRolesRestriction(repoParams, 0, -1, true);
for (RepositoryEntry entry : entries) {
AccessResult result = acManager.isAccessible(entry, retrievedUser, false);
if (result.isAccessible()) {
try {
final ICourse course = CourseFactory.loadCourse(entry);
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
if (config.isCalendarEnabled()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
} else {
CalCourseNodeVisitor visitor = new CalCourseNodeVisitor();
new CourseTreeVisitor(course, ienv).visit(visitor, new VisibleTreeFilter());
if (visitor.isFound()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
}
}
} catch (Exception e) {
log.error("", e);
}
}
}
}
if (calendarModule.isEnableGroupCalendar()) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
// start found forums in groups
BusinessGroupService bgm = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
params.addTools(CollaborationTools.TOOL_CALENDAR);
List<BusinessGroup> groups = bgm.findBusinessGroups(params, null, 0, -1);
for (BusinessGroup group : groups) {
KalendarRenderWrapper wrapper = collaborationManager.getCalendar(group, ureq, false);
calVisitor.visit(wrapper);
}
}
}
}
use of org.olat.core.id.IdentityEnvironment in project openolat by klemens.
the class IdentityCertificatesController method doGenerateCertificate.
private void doGenerateCertificate(UserRequest ureq) {
ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode rootNode = course.getRunStructure().getRootNode();
Roles roles = securityManager.getRoles(assessedIdentity);
IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, roles);
UserCourseEnvironment assessedUserCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
ScoreAccounting scoreAccounting = assessedUserCourseEnv.getScoreAccounting();
scoreAccounting.evaluateAll();
ScoreEvaluation scoreEval = scoreAccounting.evalCourseNode((AssessableCourseNode) rootNode);
CertificateTemplate template = null;
Long templateKey = course.getCourseConfig().getCertificateTemplate();
if (templateKey != null) {
template = certificatesManager.getTemplateById(templateKey);
}
Float score = scoreEval == null ? null : scoreEval.getScore();
Boolean passed = scoreEval == null ? null : scoreEval.getPassed();
CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, score, passed);
certificatesManager.generateCertificate(certificateInfos, courseEntry, template, true);
loadList();
showInfo("msg.certificate.pending");
fireEvent(ureq, Event.CHANGED_EVENT);
}
use of org.olat.core.id.IdentityEnvironment in project openolat by klemens.
the class IdentityListCourseNodeController method doSetVisibility.
private void doSetVisibility(UserRequest ureq, Boolean visibility, List<AssessedIdentityElementRow> rows) {
ICourse course = CourseFactory.loadCourse(courseEntry);
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
for (AssessedIdentityElementRow row : rows) {
Identity assessedIdentity = securityManager.loadIdentityByKey(row.getIdentityKey());
Roles roles = securityManager.getRoles(assessedIdentity);
IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, roles);
UserCourseEnvironment assessedUserCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment(), coachCourseEnv.isCourseReadOnly());
assessedUserCourseEnv.getScoreAccounting().evaluateAll();
ScoreEvaluation scoreEval = assessableCourseNode.getUserScoreEvaluation(assessedUserCourseEnv);
ScoreEvaluation doneEval = new ScoreEvaluation(scoreEval.getScore(), scoreEval.getPassed(), scoreEval.getAssessmentStatus(), visibility, scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), scoreEval.getCurrentRunStatus(), scoreEval.getAssessmentID());
assessableCourseNode.updateUserScoreEvaluation(doneEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
}
loadModel(ureq);
}
use of org.olat.core.id.IdentityEnvironment in project openolat by klemens.
the class UserSession method init.
public void init() {
store = new HashMap<String, Object>(4);
identityEnvironment = new IdentityEnvironment();
singleUserSystemBus = CoordinatorManager.getInstance().getCoordinator().createSingleUserInstance();
authenticated = false;
sessionInfo = null;
}
use of org.olat.core.id.IdentityEnvironment in project openolat by klemens.
the class UserSessionManager method signOn.
/**
* prior to calling this method, all instance vars must be set.
*/
public void signOn(UserSession usess) {
boolean isDebug = log.isDebug();
// fix a possible dead-lock see also OLAT-3390
synchronized (usess) {
if (isDebug)
log.debug("signOn() START");
if (usess.isAuthenticated()) {
throw new AssertException("sign on: already signed on!");
}
IdentityEnvironment identityEnvironment = usess.getIdentityEnvironment();
Identity identity = identityEnvironment.getIdentity();
if (identity == null) {
throw new AssertException("identity is null in identityEnvironment!");
}
SessionInfo sessionInfo = usess.getSessionInfo();
if (sessionInfo == null) {
throw new AssertException("sessionInfo was null for identity " + identity);
}
usess.setAuthenticated(true);
if (sessionInfo.isWebDAV()) {
// load user prefs
usess.reloadPreferences();
// we're only adding this webdav session to the authUserSessions - not to the userNameToIdentity.
// userNameToIdentity is only needed for IM which can't do anything with a webdav session
authUserSessions.add(usess);
log.audit("Logged on [via webdav]: " + sessionInfo.toString());
} else {
UserSession invalidatedSession = null;
if (isDebug) {
log.debug("signOn() authUsersNamesOtherNodes.contains " + identity.getName() + ": " + authUsersNamesOtherNodes.contains(identity.getKey()));
}
// check if already a session exist for this user
if ((userNameToIdentity.contains(identity.getKey()) || userSessionCache.containsKey(identity.getKey())) && !sessionInfo.isWebDAV() && !sessionInfo.isREST() && !usess.getRoles().isGuestOnly()) {
log.info("Loggin-process II: User has already a session => signOffAndClear existing session");
invalidatedSession = getUserSessionForGui(identity.getKey());
// signOffAndClear does not remove the identity.getName().toLowerCase() from the userNameToIdentity
if (invalidatedSession != null) {
authUserSessions.remove(invalidatedSession);
}
}
authUserSessions.add(usess);
// characters -> map stores values as such
if (isDebug)
log.debug("signOn() adding to userNameToIdentity: " + identity.getName().toLowerCase());
userNameToIdentity.add(identity.getKey());
userSessionCache.put(identity.getKey(), new Integer(Settings.getNodeId()));
// reload user prefs
usess.reloadPreferences();
log.audit("Logged on: " + sessionInfo.toString());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new SignOnOffEvent(identity, true), ORES_USERSESSION);
// check if a session from any browser was invalidated (IE has a cookie set per Browserinstance!!)
if (invalidatedSession != null || authUsersNamesOtherNodes.contains(identity.getKey())) {
// put flag killed-existing-session into session-store to show info-message 'only one session for each user' on user-home screen
usess.putEntry(STORE_KEY_KILLED_EXISTING_SESSION, Boolean.TRUE);
if (isDebug)
log.debug("signOn() removing from authUsersNamesOtherNodes: " + identity.getName());
authUsersNamesOtherNodes.remove(identity.getKey());
// OLAT-3381 & OLAT-3382
if (invalidatedSession != null) {
signOffAndClear(invalidatedSession);
}
}
if (isDebug)
log.debug("signOn() END");
}
// update logged in users counters
if (sessionInfo.isREST()) {
sessionCountRest.incrementAndGet();
} else if (sessionInfo.isWebDAV()) {
sessionCountDav.incrementAndGet();
} else {
sessionCountWeb.incrementAndGet();
}
}
}
Aggregations