97425: Update names of sessions enum

This commit is contained in:
Yana De Pauw
2022-12-23 12:00:44 +01:00
parent 45e4748482
commit 1cabe8e87c
3 changed files with 15 additions and 15 deletions

View File

@@ -11,9 +11,9 @@ package org.dspace.alerts;
* Enum representing the options for allowing sessions
*/
public enum AllowSessionsEnum {
ALL(0),
CURRENT(1),
ADMIN(2);
ALLOW_ALL_SESSIONS(0),
ALLOW_CURRENT_SESSIONS_ONLY(1),
ALLOW_ADMIN_SESSIONS_ONLY(2);
private int allowSessionsType;
@@ -27,16 +27,16 @@ public enum AllowSessionsEnum {
public static AllowSessionsEnum fromInt(Integer alertAllowSessionType) {
if (alertAllowSessionType == null) {
return AllowSessionsEnum.ALL;
return AllowSessionsEnum.ALLOW_ALL_SESSIONS;
}
switch (alertAllowSessionType) {
case 0:
return AllowSessionsEnum.ALL;
return AllowSessionsEnum.ALLOW_ALL_SESSIONS;
case 1:
return AllowSessionsEnum.CURRENT;
return AllowSessionsEnum.ALLOW_CURRENT_SESSIONS_ONLY;
case 2:
return AllowSessionsEnum.ADMIN;
return AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY;
default:
throw new IllegalArgumentException("No corresponding enum value for integer");
}

View File

@@ -94,7 +94,7 @@ public class SystemWideAlertServiceImpl implements SystemWideAlertService {
if (active == null || active.isEmpty()) {
return true;
}
return active.get(0).getAllowSessions() == AllowSessionsEnum.ALL.getValue();
return active.get(0).getAllowSessions() == AllowSessionsEnum.ALLOW_ALL_SESSIONS.getValue();
}
public boolean canUserMaintainSession(Context context, EPerson ePerson) throws SQLException {
@@ -105,6 +105,6 @@ public class SystemWideAlertServiceImpl implements SystemWideAlertService {
if (active == null || active.isEmpty()) {
return true;
}
return active.get(0).getAllowSessions() != AllowSessionsEnum.ADMIN.getValue();
return active.get(0).getAllowSessions() != AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY.getValue();
}
}

View File

@@ -69,10 +69,10 @@ public class SystemWideAlertRestRepositoryIT extends AbstractControllerIntegrati
public void findAllTest() throws Exception {
Date countdownDate = new Date();
SystemWideAlert systemWideAlert1 = systemWideAlertService.create(context, "Test alert 1",
AllowSessionsEnum.CURRENT, countdownDate,
AllowSessionsEnum.ALLOW_CURRENT_SESSIONS_ONLY, countdownDate,
true);
SystemWideAlert systemWideAlert2 = systemWideAlertService.create(context, "Test alert 2",
AllowSessionsEnum.ADMIN, null,
AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY, null,
false);
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
getClient().perform(get("/api/system/systemwidealerts/"))
@@ -103,10 +103,10 @@ public class SystemWideAlertRestRepositoryIT extends AbstractControllerIntegrati
Date countdownDate = new Date();
SystemWideAlert systemWideAlert1 = systemWideAlertService.create(context, "Test alert 1",
AllowSessionsEnum.CURRENT, countdownDate,
AllowSessionsEnum.ALLOW_CURRENT_SESSIONS_ONLY, countdownDate,
true);
SystemWideAlert systemWideAlert2 = systemWideAlertService.create(context, "Test alert 2",
AllowSessionsEnum.ADMIN, null,
AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY, null,
false);
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
getClient().perform(get("/api/system/systemwidealerts/" + systemWideAlert1.getID()))
@@ -216,7 +216,7 @@ public class SystemWideAlertRestRepositoryIT extends AbstractControllerIntegrati
public void createWhenAlreadyExistsTest() throws Exception {
SystemWideAlert systemWideAlert = systemWideAlertService.create(context, "Test alert",
AllowSessionsEnum.ADMIN, null,
AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY, null,
false);
SystemWideAlertRest systemWideAlertRest = new SystemWideAlertRest();
@@ -240,7 +240,7 @@ public class SystemWideAlertRestRepositoryIT extends AbstractControllerIntegrati
public void putTest() throws Exception {
SystemWideAlert systemWideAlert = systemWideAlertService.create(context, "Alert test message",
AllowSessionsEnum.ADMIN, null,
AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY, null,
false);
SystemWideAlertRest systemWideAlertRest = new SystemWideAlertRest();