mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00
97425: Update names of sessions enum
This commit is contained in:
@@ -11,9 +11,9 @@ package org.dspace.alerts;
|
|||||||
* Enum representing the options for allowing sessions
|
* Enum representing the options for allowing sessions
|
||||||
*/
|
*/
|
||||||
public enum AllowSessionsEnum {
|
public enum AllowSessionsEnum {
|
||||||
ALL(0),
|
ALLOW_ALL_SESSIONS(0),
|
||||||
CURRENT(1),
|
ALLOW_CURRENT_SESSIONS_ONLY(1),
|
||||||
ADMIN(2);
|
ALLOW_ADMIN_SESSIONS_ONLY(2);
|
||||||
|
|
||||||
private int allowSessionsType;
|
private int allowSessionsType;
|
||||||
|
|
||||||
@@ -27,16 +27,16 @@ public enum AllowSessionsEnum {
|
|||||||
|
|
||||||
public static AllowSessionsEnum fromInt(Integer alertAllowSessionType) {
|
public static AllowSessionsEnum fromInt(Integer alertAllowSessionType) {
|
||||||
if (alertAllowSessionType == null) {
|
if (alertAllowSessionType == null) {
|
||||||
return AllowSessionsEnum.ALL;
|
return AllowSessionsEnum.ALLOW_ALL_SESSIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (alertAllowSessionType) {
|
switch (alertAllowSessionType) {
|
||||||
case 0:
|
case 0:
|
||||||
return AllowSessionsEnum.ALL;
|
return AllowSessionsEnum.ALLOW_ALL_SESSIONS;
|
||||||
case 1:
|
case 1:
|
||||||
return AllowSessionsEnum.CURRENT;
|
return AllowSessionsEnum.ALLOW_CURRENT_SESSIONS_ONLY;
|
||||||
case 2:
|
case 2:
|
||||||
return AllowSessionsEnum.ADMIN;
|
return AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("No corresponding enum value for integer");
|
throw new IllegalArgumentException("No corresponding enum value for integer");
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ public class SystemWideAlertServiceImpl implements SystemWideAlertService {
|
|||||||
if (active == null || active.isEmpty()) {
|
if (active == null || active.isEmpty()) {
|
||||||
return true;
|
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 {
|
public boolean canUserMaintainSession(Context context, EPerson ePerson) throws SQLException {
|
||||||
@@ -105,6 +105,6 @@ public class SystemWideAlertServiceImpl implements SystemWideAlertService {
|
|||||||
if (active == null || active.isEmpty()) {
|
if (active == null || active.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return active.get(0).getAllowSessions() != AllowSessionsEnum.ADMIN.getValue();
|
return active.get(0).getAllowSessions() != AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,10 +69,10 @@ public class SystemWideAlertRestRepositoryIT extends AbstractControllerIntegrati
|
|||||||
public void findAllTest() throws Exception {
|
public void findAllTest() throws Exception {
|
||||||
Date countdownDate = new Date();
|
Date countdownDate = new Date();
|
||||||
SystemWideAlert systemWideAlert1 = systemWideAlertService.create(context, "Test alert 1",
|
SystemWideAlert systemWideAlert1 = systemWideAlertService.create(context, "Test alert 1",
|
||||||
AllowSessionsEnum.CURRENT, countdownDate,
|
AllowSessionsEnum.ALLOW_CURRENT_SESSIONS_ONLY, countdownDate,
|
||||||
true);
|
true);
|
||||||
SystemWideAlert systemWideAlert2 = systemWideAlertService.create(context, "Test alert 2",
|
SystemWideAlert systemWideAlert2 = systemWideAlertService.create(context, "Test alert 2",
|
||||||
AllowSessionsEnum.ADMIN, null,
|
AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY, null,
|
||||||
false);
|
false);
|
||||||
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
getClient().perform(get("/api/system/systemwidealerts/"))
|
getClient().perform(get("/api/system/systemwidealerts/"))
|
||||||
@@ -103,10 +103,10 @@ public class SystemWideAlertRestRepositoryIT extends AbstractControllerIntegrati
|
|||||||
|
|
||||||
Date countdownDate = new Date();
|
Date countdownDate = new Date();
|
||||||
SystemWideAlert systemWideAlert1 = systemWideAlertService.create(context, "Test alert 1",
|
SystemWideAlert systemWideAlert1 = systemWideAlertService.create(context, "Test alert 1",
|
||||||
AllowSessionsEnum.CURRENT, countdownDate,
|
AllowSessionsEnum.ALLOW_CURRENT_SESSIONS_ONLY, countdownDate,
|
||||||
true);
|
true);
|
||||||
SystemWideAlert systemWideAlert2 = systemWideAlertService.create(context, "Test alert 2",
|
SystemWideAlert systemWideAlert2 = systemWideAlertService.create(context, "Test alert 2",
|
||||||
AllowSessionsEnum.ADMIN, null,
|
AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY, null,
|
||||||
false);
|
false);
|
||||||
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
getClient().perform(get("/api/system/systemwidealerts/" + systemWideAlert1.getID()))
|
getClient().perform(get("/api/system/systemwidealerts/" + systemWideAlert1.getID()))
|
||||||
@@ -216,7 +216,7 @@ public class SystemWideAlertRestRepositoryIT extends AbstractControllerIntegrati
|
|||||||
public void createWhenAlreadyExistsTest() throws Exception {
|
public void createWhenAlreadyExistsTest() throws Exception {
|
||||||
|
|
||||||
SystemWideAlert systemWideAlert = systemWideAlertService.create(context, "Test alert",
|
SystemWideAlert systemWideAlert = systemWideAlertService.create(context, "Test alert",
|
||||||
AllowSessionsEnum.ADMIN, null,
|
AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY, null,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
SystemWideAlertRest systemWideAlertRest = new SystemWideAlertRest();
|
SystemWideAlertRest systemWideAlertRest = new SystemWideAlertRest();
|
||||||
@@ -240,7 +240,7 @@ public class SystemWideAlertRestRepositoryIT extends AbstractControllerIntegrati
|
|||||||
public void putTest() throws Exception {
|
public void putTest() throws Exception {
|
||||||
|
|
||||||
SystemWideAlert systemWideAlert = systemWideAlertService.create(context, "Alert test message",
|
SystemWideAlert systemWideAlert = systemWideAlertService.create(context, "Alert test message",
|
||||||
AllowSessionsEnum.ADMIN, null,
|
AllowSessionsEnum.ALLOW_ADMIN_SESSIONS_ONLY, null,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
SystemWideAlertRest systemWideAlertRest = new SystemWideAlertRest();
|
SystemWideAlertRest systemWideAlertRest = new SystemWideAlertRest();
|
||||||
|
Reference in New Issue
Block a user