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

Merge OpenOLAT 9.4 to OpenOLATpro 9.4 with ee262816b7699fc0801ba7b837ea4e81341df37a

parents 6aa7dfe0 f26eee9a
No related branches found
No related tags found
No related merge requests found
...@@ -72,3 +72,4 @@ cee7299c2b62edf89f6164ab81f3b785a234f95b OpenOLAT 9.3.2 ...@@ -72,3 +72,4 @@ cee7299c2b62edf89f6164ab81f3b785a234f95b OpenOLAT 9.3.2
3e4c2cc8495ac15f4af7397382655cfee1420336 OpenOLAT 9.3.5 3e4c2cc8495ac15f4af7397382655cfee1420336 OpenOLAT 9.3.5
9a5d02062c328f6ab31aae75d02e7170c81fb459 OpenOLAT 9.4.0 9a5d02062c328f6ab31aae75d02e7170c81fb459 OpenOLAT 9.4.0
2ee79964af9b646839064c65e12b4e6850d06c2d OpenOLAT 9.4.1 2ee79964af9b646839064c65e12b4e6850d06c2d OpenOLAT 9.4.1
2205a77012cfb955415464ef779cb1012225bf79 OpenOLAT 9.4.2
...@@ -291,7 +291,7 @@ public class UserBulkChangeManager extends BasicManager { ...@@ -291,7 +291,7 @@ public class UserBulkChangeManager extends BasicManager {
UserManager.getInstance().getUserDisplayName(identity.getUser()),// 2: Name (first and last name) of user who changed the password UserManager.getInstance().getUserDisplayName(identity.getUser()),// 2: Name (first and last name) of user who changed the password
WebappHelper.getMailConfig("mailSupport"), //3: configured support email address WebappHelper.getMailConfig("mailSupport"), //3: configured support email address
identity.getUser().getProperty(UserConstants.LASTNAME, null), //4 last name identity.getUser().getProperty(UserConstants.LASTNAME, null), //4 last name
Settings.getSecureServerContextPathURI(), //5 url system getServerURI(), //5 url system
gender //6 Mr. Mrs. gender //6 Mr. Mrs.
}; };
...@@ -301,6 +301,14 @@ public class UserBulkChangeManager extends BasicManager { ...@@ -301,6 +301,14 @@ public class UserBulkChangeManager extends BasicManager {
translator.translate("mailtemplate.login.denied.body", args)); translator.translate("mailtemplate.login.denied.body", args));
CoreSpringFactory.getImpl(MailManager.class).sendExternMessage(bundle, null); CoreSpringFactory.getImpl(MailManager.class).sendExternMessage(bundle, null);
} }
private String getServerURI() {
String uri = Settings.getSecureServerContextPathURI();
if(StringHelper.containsNonWhitespace(uri)) {
return uri;
}
return Settings.getInsecureServerContextPathURI();
}
public String evaluateValueWithUserContext(String valToEval, Context vcContext) { public String evaluateValueWithUserContext(String valToEval, Context vcContext) {
StringWriter evaluatedUserValue = new StringWriter(); StringWriter evaluatedUserValue = new StringWriter();
......
...@@ -158,6 +158,19 @@ public class InvitationDAO { ...@@ -158,6 +158,19 @@ public class InvitationDAO {
return invitations.isEmpty() ? null : invitations.get(0); return invitations.isEmpty() ? null : invitations.get(0);
} }
/**
* the number of invitations
* @return
*/
public long countInvitations() {
String sb = "select count(invitation) from binvitation as invitation";
Number invitations = dbInstance.getCurrentEntityManager()
.createQuery(sb, Number.class)
.getSingleResult();
return invitations == null ? 0l : invitations.longValue();
}
/** /**
* Check if the identity has an invitation, valid or not * Check if the identity has an invitation, valid or not
* @param identity * @param identity
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
*/ */
package org.olat.restapi.system; package org.olat.restapi.system;
import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -33,12 +34,14 @@ import org.olat.admin.sysinfo.model.SessionsStats; ...@@ -33,12 +34,14 @@ import org.olat.admin.sysinfo.model.SessionsStats;
import org.olat.basesecurity.BaseSecurity; import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.Constants; import org.olat.basesecurity.Constants;
import org.olat.core.CoreSpringFactory; import org.olat.core.CoreSpringFactory;
import org.olat.core.id.Identity;
import org.olat.core.util.SessionInfo; import org.olat.core.util.SessionInfo;
import org.olat.core.util.UserSession; import org.olat.core.util.UserSession;
import org.olat.core.util.WorkThreadInformations; import org.olat.core.util.WorkThreadInformations;
import org.olat.core.util.session.UserSessionManager; import org.olat.core.util.session.UserSessionManager;
import org.olat.course.CourseModule; import org.olat.course.CourseModule;
import org.olat.group.BusinessGroupService; import org.olat.group.BusinessGroupService;
import org.olat.portfolio.manager.InvitationDAO;
import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryManager; import org.olat.repository.RepositoryManager;
import org.olat.restapi.system.vo.OpenOLATStatisticsVO; import org.olat.restapi.system.vo.OpenOLATStatisticsVO;
...@@ -165,13 +168,51 @@ public class OpenOLATStatisticsWebService implements Sampler { ...@@ -165,13 +168,51 @@ public class OpenOLATStatisticsWebService implements Sampler {
private UserStatisticsVO getUserStatisticsVO() { private UserStatisticsVO getUserStatisticsVO() {
UserStatisticsVO stats = new UserStatisticsVO(); UserStatisticsVO stats = new UserStatisticsVO();
BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class); BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
long countUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, null);
stats.setTotalUserCount(countUsers); // activeUserCount="88" // registered and activated identities, same as in GUI
long countActiveUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, Constants.USERSTATUS_ACTIVE); long countActiveUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, Constants.USERSTATUS_ACTIVE);
stats.setActiveUserCount(countActiveUsers); stats.setActiveUserCount(countActiveUsers);
// active last week
Calendar lastDay = Calendar.getInstance();
lastDay.add(Calendar.DATE, -1);
long activeUserCountDay = securityManager.countUniqueUserLoginsSince(lastDay.getTime());
stats.setActiveUserCountLastDay(activeUserCountDay);
// active last week
Calendar lastWeek = Calendar.getInstance();
lastWeek.add(Calendar.DATE, -7);
long activeUserCountWeek = securityManager.countUniqueUserLoginsSince(lastWeek.getTime());
stats.setActiveUserCountLastWeek(activeUserCountWeek);
// active last month
Calendar lastMonth = Calendar.getInstance();
lastMonth.add(Calendar.MONTH, -1);
long activeUserCountMonth = securityManager.countUniqueUserLoginsSince(lastMonth.getTime());
stats.setActiveUserCountLastMonth(activeUserCountMonth);
// active last 6 month
Calendar last6Month = Calendar.getInstance();
last6Month.add(Calendar.MONTH, -6);
long activeUserCount6Month = securityManager.countUniqueUserLoginsSince(last6Month.getTime());
stats.setActiveUserCountLast6Month(activeUserCount6Month);
// externalUserCount="12" // EP invite identities, later maybe also used in courses for MOOCS, external experts etc)
long invitationsCount = CoreSpringFactory.getImpl(InvitationDAO.class).countInvitations();
stats.setExternalUserCount(invitationsCount);
// blockedUserCount="0" // identities in login blocked state
long blockedUserCount = securityManager.countIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_LOGIN_DENIED);
stats.setBlockedUserCount(blockedUserCount);
// deletedUserCount="943" // deleted identities
long deletedUserCount = securityManager.countIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_DELETED);
stats.setDeletedUserCount(deletedUserCount);
// totalUserCount="1043" // Sum of all above
long countUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, null);
stats.setTotalUserCount(countUsers);
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class); BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
long countGroups = bgs.countBusinessGroups(null, null); long countGroups = bgs.countBusinessGroups(null, null);
stats.setTotalGroupCount(countGroups); stats.setTotalGroupCount(countGroups);
......
...@@ -34,12 +34,25 @@ public class UserStatisticsVO { ...@@ -34,12 +34,25 @@ public class UserStatisticsVO {
@XmlAttribute(name="totalUserCount", required=true) @XmlAttribute(name="totalUserCount", required=true)
private long totalUserCount; private long totalUserCount;
@XmlAttribute(name="activeUserCount", required=true) @XmlAttribute(name="activeUserCount", required=false)
private long activeUserCount; private long activeUserCount;
@XmlAttribute(name="activeUserCountLastDay", required=false)
private long activeUserCountLastDay;
@XmlAttribute(name="activeUserCountLastWeek", required=false)
private long activeUserCountLastWeek;
@XmlAttribute(name="activeUserCountLastMonth", required=false)
private long activeUserCountLastMonth;
@XmlAttribute(name="activeUserCountLast6Month", required=false)
private long activeUserCountLast6Month;
@XmlAttribute(name="externalUserCount", required=false)
private long externalUserCount;
@XmlAttribute(name="blockedUserCount", required=false)
private long blockedUserCount;
@XmlAttribute(name="deletedUserCount", required=false)
private long deletedUserCount;
@XmlAttribute(name="totalGroupCount", required=true) @XmlAttribute(name="totalGroupCount", required=true)
private long totalGroupCount; private long totalGroupCount;
public long getTotalUserCount() { public long getTotalUserCount() {
return totalUserCount; return totalUserCount;
} }
...@@ -55,7 +68,63 @@ public class UserStatisticsVO { ...@@ -55,7 +68,63 @@ public class UserStatisticsVO {
public void setActiveUserCount(long activeUserCount) { public void setActiveUserCount(long activeUserCount) {
this.activeUserCount = activeUserCount; this.activeUserCount = activeUserCount;
} }
public long getActiveUserCountLastDay() {
return activeUserCountLastDay;
}
public void setActiveUserCountLastDay(long activeUserCountLastDay) {
this.activeUserCountLastDay = activeUserCountLastDay;
}
public long getActiveUserCountLastWeek() {
return activeUserCountLastWeek;
}
public void setActiveUserCountLastWeek(long activeUserCountLastWeek) {
this.activeUserCountLastWeek = activeUserCountLastWeek;
}
public long getActiveUserCountLastMonth() {
return activeUserCountLastMonth;
}
public void setActiveUserCountLastMonth(long activeUserCountLastMonth) {
this.activeUserCountLastMonth = activeUserCountLastMonth;
}
public long getActiveUserCountLast6Month() {
return activeUserCountLast6Month;
}
public void setActiveUserCountLast6Month(long activeUserCountLast6Month) {
this.activeUserCountLast6Month = activeUserCountLast6Month;
}
public long getExternalUserCount() {
return externalUserCount;
}
public void setExternalUserCount(long externalUserCount) {
this.externalUserCount = externalUserCount;
}
public long getBlockedUserCount() {
return blockedUserCount;
}
public void setBlockedUserCount(long blockedUserCount) {
this.blockedUserCount = blockedUserCount;
}
public long getDeletedUserCount() {
return deletedUserCount;
}
public void setDeletedUserCount(long deletedUserCount) {
this.deletedUserCount = deletedUserCount;
}
public long getTotalGroupCount() { public long getTotalGroupCount() {
return totalGroupCount; return totalGroupCount;
} }
......
...@@ -107,6 +107,16 @@ public class InvitationDAOTest extends OlatTestCase { ...@@ -107,6 +107,16 @@ public class InvitationDAOTest extends OlatTestCase {
Assert.assertEquals("kanu.unchou@frentix.com", reloadedInvitation.getMail()); Assert.assertEquals("kanu.unchou@frentix.com", reloadedInvitation.getMail());
} }
@Test
public void countInvitations() {
Invitation invitation = invitationDao.createAndPersistInvitation();
dbInstance.commit();
Assert.assertNotNull(invitation);
long numOfInvitations = invitationDao.countInvitations();
Assert.assertTrue(numOfInvitations > 0l);
}
/** /**
* Check the HQL code of the the method, and that it doesn't delete to much invitations * Check the HQL code of the the method, and that it doesn't delete to much invitations
*/ */
......
...@@ -153,11 +153,36 @@ public class SystemTest extends OlatJerseyTestCase { ...@@ -153,11 +153,36 @@ public class SystemTest extends OlatJerseyTestCase {
URI systemUri = conn.getContextURI().path("system").path("monitoring").path("openolat").path("users").build(); URI systemUri = conn.getContextURI().path("system").path("monitoring").path("openolat").path("users").build();
UserStatisticsVO userStats = conn.get(systemUri, UserStatisticsVO.class); UserStatisticsVO userStats = conn.get(systemUri, UserStatisticsVO.class);
assertNotNull(userStats); assertNotNull(userStats);
assertTrue(userStats.getTotalUserCount() > 0);
assertTrue(userStats.getTotalGroupCount() >= 0); long totalUserCount = userStats.getTotalUserCount();
assertTrue(userStats.getActiveUserCount() >= 0); assertTrue(totalUserCount > 0);
long activeUserCount = userStats.getActiveUserCount();
assertTrue(activeUserCount >= 0);
long activeUserCountLastDay = userStats.getActiveUserCountLastDay();
assertTrue(activeUserCountLastDay >= 0);
long activeUserCountLastWeek = userStats.getActiveUserCountLastWeek();
assertTrue(activeUserCountLastWeek >= 0);
long activeUserCountLastMonth = userStats.getActiveUserCountLastMonth();
assertTrue(activeUserCountLastMonth >= 0);
long activeUserCountLast6Month = userStats.getActiveUserCountLast6Month();
assertTrue(activeUserCountLast6Month >= 0);
long blockedUserCount = userStats.getBlockedUserCount();
assertTrue(blockedUserCount >= 0);
long deletedUserCount = userStats.getDeletedUserCount();
assertTrue(deletedUserCount >= 0);
long externalUserCount = userStats.getExternalUserCount();
assertTrue(externalUserCount >= 0);
long totalGroupCount = userStats.getTotalGroupCount();
assertTrue(totalGroupCount >= 0);
conn.shutdown(); conn.shutdown();
} }
......
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