Skip to content

Commit 4715174

Browse files
committed
Create a path for getting system settings without a permissions check to enable system level functionality
1 parent ee03956 commit 4715174

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

server/src/main/java/com/objectcomputing/checkins/notifications/email/MailJetFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ MailjetClient getClient() {
3131
String mj_apikey_private;
3232

3333
try {
34-
mj_apikey_public = settingsServices.findByName(SettingOption.MJ_APIKEY_PUBLIC.name()).getValue();
34+
mj_apikey_public = settingsServices.systemFindByName(SettingOption.MJ_APIKEY_PUBLIC.name()).getValue();
3535
} catch (NotFoundException e) {
3636
mj_apikey_public = "";
3737
}
3838
try {
39-
mj_apikey_private = settingsServices.findByName(SettingOption.MJ_APIKEY_PRIVATE.name()).getValue();
39+
mj_apikey_private = settingsServices.systemFindByName(SettingOption.MJ_APIKEY_PRIVATE.name()).getValue();
4040
} catch (NotFoundException e) {
4141
mj_apikey_private = "";
4242
}

server/src/main/java/com/objectcomputing/checkins/notifications/email/MailJetSender.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public class MailJetSender implements EmailSender {
3535

3636
private String getFromAddress() {
3737
try {
38-
return settingsServices.findByName(SettingOption.FROM_ADDRESS.name()).getValue();
38+
return settingsServices.systemFindByName(SettingOption.FROM_ADDRESS.name()).getValue();
3939
} catch (NotFoundException e) {
4040
return "";
4141
}
4242
}
4343

4444
private String getFromName() {
4545
try {
46-
return settingsServices.findByName(SettingOption.FROM_NAME.name()).getValue();
46+
return settingsServices.systemFindByName(SettingOption.FROM_NAME.name()).getValue();
4747
} catch (NotFoundException e) {
4848
return "";
4949
}
@@ -104,12 +104,12 @@ public void sendEmail(String fromName, String fromAddress, String subject, Strin
104104
String mj_apikey_public;
105105
String mj_apikey_private;
106106
try {
107-
mj_apikey_public = settingsServices.findByName(SettingOption.MJ_APIKEY_PUBLIC.name()).getValue();
107+
mj_apikey_public = settingsServices.systemFindByName(SettingOption.MJ_APIKEY_PUBLIC.name()).getValue();
108108
} catch (NotFoundException e) {
109109
mj_apikey_public = "";
110110
}
111111
try {
112-
mj_apikey_private = settingsServices.findByName(SettingOption.MJ_APIKEY_PRIVATE.name()).getValue();
112+
mj_apikey_private = settingsServices.systemFindByName(SettingOption.MJ_APIKEY_PRIVATE.name()).getValue();
113113
} catch (NotFoundException e) {
114114
mj_apikey_private = "";
115115
}

server/src/main/java/com/objectcomputing/checkins/services/file/FileServicesImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected void getCheckinDocuments(
9595
private String getRootDirId() {
9696
String rootDirId;
9797
try {
98-
rootDirId = settingsServices.findByName(SettingOption.DIRECTORY_ID.name()).getValue();
98+
rootDirId = settingsServices.systemFindByName(SettingOption.DIRECTORY_ID.name()).getValue();
9999
}
100100
catch (NotFoundException e ) {
101101
rootDirId = "";

server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseServicesImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void notifyUsers(LocalDate check) {
7878
.with(TemporalAdjusters.firstInMonth(emailDay));
7979

8080
try {
81-
Setting freq = settingsServices.findByName("PULSE_EMAIL_FREQUENCY");
81+
Setting freq = settingsServices.systemFindByName("PULSE_EMAIL_FREQUENCY");
8282
if (frequency.containsKey(freq.getValue())) {
8383
setting = freq.getValue();
8484
} else {

server/src/main/java/com/objectcomputing/checkins/services/settings/SettingsServices.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public interface SettingsServices {
1313

1414
Setting findByName(@NotNull String name);
1515

16+
Setting systemFindByName(@NotNull String name);
17+
1618
List<Setting> findAllSettings();
1719

1820
boolean delete(UUID id);

server/src/main/java/com/objectcomputing/checkins/services/settings/SettingsServicesImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public Setting findByName(@NotNull String name) {
5353
.orElseThrow(() -> new NotFoundException("Setting with name " + name + " not found."));
5454
}
5555

56+
@Override
57+
public Setting systemFindByName(@NotNull String name) {
58+
return settingsRepository.findByName(name)
59+
.orElseThrow(() -> new NotFoundException("Setting with name " + name + " not found."));
60+
}
61+
5662
@Override
5763
@RequiredPermission(Permission.CAN_VIEW_SETTINGS)
5864
public List<Setting> findAllSettings() {

0 commit comments

Comments
 (0)