diff --git a/README.md b/README.md index 2eb25453..2e2ec9cd 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,13 @@ This application requires a Java 11+ JVM and standard library to run, plus a Jav Wildfly must be pre-configured before the first deployment of the app. The [wildfly bash scripts](https://github.com/JeffersonLab/wildfly#configure) can be used to accomplish this. See the [Dockerfile](https://github.com/JeffersonLab/jam/blob/main/Dockerfile) for an example. ### Runtime -Uses the [Smoothness Environment Variables](https://github.com/JeffersonLab/smoothness#global-runtime) plus the following application specific: +Uses the [Smoothness Environment Variables](https://github.com/JeffersonLab/smoothness#global-runtime) plus the following application specific Settings: | Name | Description | |-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| -| JAM_EMAIL_SENDER | Sender (and from address) of emails. Defaults to `jam@jlab.org` | -| JAM_COMPONENT_DETAIL_URL | URL for Component detail linking. Example: https://ace.jlab.org/srm/reports/component?name= | -| JAM_COMPONENT_QUERY_URL | URL for Component search. Proxied. Example: https://ace.jlab.org/srm/data/components | -| JAM_USER_QUERY_URL | URL for User search. Proxied. Example: https://ace.jlab.org/srm/ajax/search-user | +| COMPONENT_DETAIL_URL | URL for Component detail linking. Example: https://ace.jlab.org/srm/reports/component?name= | +| COMPONENT_QUERY_URL | URL for Component search. Proxied. Example: https://ace.jlab.org/srm/data/components | +| USER_QUERY_URL | URL for User search. Proxied. Example: https://ace.jlab.org/srm/ajax/search-user | ### Database This application requires an Oracle 18+ database with the following [schema](https://github.com/JeffersonLab/jam/tree/main/container/oracle/initdb.d) installed. The application server hosting this app must also be configured with a JNDI datasource. diff --git a/compose.yaml b/compose.yaml index c6f41c6c..b5531c8e 100644 --- a/compose.yaml +++ b/compose.yaml @@ -40,7 +40,6 @@ services: JAM_UPCOMING_EXPIRATION_SUBJECT: '[TESTING] Authorization Expired / Expiring Soon' JAM_EXPIRED_SUBJECT: '[TESTING] Authorization Expired' JAM_DOWNGRADED_SUBJECT: '[TESTING] Authorization Downgraded' - JAM_EMAIL_SENDER: 'jam@example.com' KEYCLOAK_REALM: 'test-realm' KEYCLOAK_RESOURCE: 'jam' KEYCLOAK_SECRET: 'yHi6W2raPmLvPXoxqMA7VWbLAA2WN0eB' diff --git a/container/oracle/initdb.d/04_settings.sql b/container/oracle/initdb.d/04_settings.sql index bbace87d..9b6d038d 100644 --- a/container/oracle/initdb.d/04_settings.sql +++ b/container/oracle/initdb.d/04_settings.sql @@ -31,4 +31,9 @@ insert into SETTING (KEY, VALUE, TYPE, DESCRIPTION, TAG, WEIGHT) values ('HELP_D insert into SETTING (KEY, VALUE, TYPE, DESCRIPTION, TAG, WEIGHT) values ('EMAIL_ENABLED', 'Y', 'BOOLEAN', 'Emails (including Help/Feedback) enabled', 'EMAIL', 1); insert into SETTING (KEY, VALUE, TYPE, DESCRIPTION, TAG, WEIGHT) values ('EMAIL_TESTING_ENABLED', 'N', 'BOOLEAN', 'Send all emails to testlead user group', 'EMAIL', 2); insert into SETTING (KEY, VALUE, TYPE, DESCRIPTION, TAG, WEIGHT) values ('EMAIL_DOMAIN_NAME', '@jlab.org', 'STRING', 'The email domain to append to usernames, starting with and including the ampersat.', 'EMAIL', 3); -insert into SETTING (KEY, VALUE, TYPE, DESCRIPTION, TAG, WEIGHT) values ('EMAIL_SENDER_ADDRESS', 'cnm@jlab.org', 'STRING', 'Email address to use as sender from emails generated in this app. Note: this is not the same as "from".', 'EMAIL', 4); +insert into SETTING (KEY, VALUE, TYPE, DESCRIPTION, TAG, WEIGHT) values ('EMAIL_SENDER_ADDRESS', 'jam@jlab.org', 'STRING', 'Email address to use as sender from emails generated in this app. Note: this is not the same as "from".', 'EMAIL', 4); + +-- JAM Specific +insert into SETTING (KEY, VALUE, TYPE, DESCRIPTION, TAG, WEIGHT) values ('USER_QUERY_URL', 'https://ace.jlab.org/srm/ajax/search-user', 'STRING', 'URL to query for users', 'JAM', 1); +insert into SETTING (KEY, VALUE, TYPE, DESCRIPTION, TAG, WEIGHT) values ('COMPONENT_QUERY_URL', 'https://ace.jlab.org/srm/data/components', 'STRING', 'URL to query for components', 'JAM', 2); +insert into SETTING (KEY, VALUE, TYPE, DESCRIPTION, TAG, WEIGHT) values ('COMPONENT_DETAIL_URL', 'https://ace.jlab.org/srm/reports/component?name=', 'STRING', 'URL to link component details', 'JAM', 3); diff --git a/src/main/java/org/jlab/jam/business/session/EmailFacade.java b/src/main/java/org/jlab/jam/business/session/EmailFacade.java index 0e654574..e4a3b9c8 100644 --- a/src/main/java/org/jlab/jam/business/session/EmailFacade.java +++ b/src/main/java/org/jlab/jam/business/session/EmailFacade.java @@ -315,10 +315,10 @@ private void sendUpcomingToAdminsAndFacilityManager(FacilityUpcomingExpiration u try { EmailService emailService = new EmailService(); - String sender = System.getenv("JAM_EMAIL_SENDER"); + String sender = SettingsService.cachedSettings.get("EMAIL_SENDER_ADDRESS"); if (sender == null) { - sender = "jam@jlab.org"; + throw new RuntimeException("Configure EMAIL_SENDER_ADDRESS Setting in DB"); } boolean testing = false; @@ -406,10 +406,10 @@ public void sendWatcherAuthorizationUpdateEmail( imagePart.addHeader("Content-Type", "image/png"); multipart.addBodyPart(imagePart); - String sender = System.getenv("JAM_EMAIL_SENDER"); + String sender = SettingsService.cachedSettings.get("EMAIL_SENDER_ADDRESS"); if (sender == null) { - sender = "jam@jlab.org"; + throw new RuntimeException("Configure EMAIL_SENDER_ADDRESS Setting in DB"); } String toCsv = ""; @@ -494,10 +494,10 @@ public void sendAdminAndManagerAuthorizationUpdateEmail( imagePart.addHeader("Content-Type", "image/png"); multipart.addBodyPart(imagePart); - String sender = System.getenv("JAM_EMAIL_SENDER"); + String sender = SettingsService.cachedSettings.get("EMAIL_SENDER_ADDRESS"); if (sender == null) { - sender = "jam@jlab.org"; + throw new RuntimeException("Configure EMAIL_SENDER_ADDRESS Setting in DB"); } String toCsv = IOUtil.toCsv(addressList.toArray()); @@ -567,10 +567,10 @@ public void sendVerificationTeamsAuthorizationUpdateEmail( imagePart.addHeader("Content-Type", "image/png"); multipart.addBodyPart(imagePart); - String sender = System.getenv("JAM_EMAIL_SENDER"); + String sender = SettingsService.cachedSettings.get("EMAIL_SENDER_ADDRESS"); if (sender == null) { - sender = "jam@jlab.org"; + throw new RuntimeException("Configure EMAIL_SENDER_ADDRESS Setting in DB"); } String toCsv = IOUtil.toCsv(addressList.toArray()); @@ -595,10 +595,10 @@ private void sendUpcomingToVerificationTeam(Facility facility, TeamUpcoming upco try { EmailService emailService = new EmailService(); - String sender = System.getenv("JAM_EMAIL_SENDER"); + String sender = SettingsService.cachedSettings.get("EMAIL_SENDER_ADDRESS"); if (sender == null) { - sender = "jam@jlab.org"; + throw new RuntimeException("Configure EMAIL_SENDER_ADDRESS Setting in DB"); } String subject = "JAM: " + facility.getName() + " Upcoming Expiration Notice"; diff --git a/src/main/java/org/jlab/jam/presentation/controller/ajax/ComponentSearch.java b/src/main/java/org/jlab/jam/presentation/controller/ajax/ComponentSearch.java index 97d75df6..b7daca93 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/ajax/ComponentSearch.java +++ b/src/main/java/org/jlab/jam/presentation/controller/ajax/ComponentSearch.java @@ -13,6 +13,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.jlab.smoothness.business.service.SettingsService; import org.jlab.smoothness.presentation.util.ParamBuilder; import org.jlab.smoothness.presentation.util.ServletUtil; @@ -44,10 +45,10 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) String q = request.getParameter("q"); // https://ace.jlab.org/srm/data/components - String COMPONENT_QUERY_URL = System.getenv("JAM_COMPONENT_QUERY_URL"); + String COMPONENT_QUERY_URL = SettingsService.cachedSettings.get("COMPONENT_QUERY_URL"); if (COMPONENT_QUERY_URL == null) { - throw new ServletException("JAM_COMPONENT_QUERY_URL not set"); + throw new ServletException("COMPONENT_QUERY_URL not set"); } ParamBuilder builder = new ParamBuilder(); diff --git a/src/main/java/org/jlab/jam/presentation/controller/ajax/UserSearch.java b/src/main/java/org/jlab/jam/presentation/controller/ajax/UserSearch.java index 632c5daf..fabeb8b4 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/ajax/UserSearch.java +++ b/src/main/java/org/jlab/jam/presentation/controller/ajax/UserSearch.java @@ -13,6 +13,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.jlab.smoothness.business.service.SettingsService; import org.jlab.smoothness.presentation.util.ParamBuilder; import org.jlab.smoothness.presentation.util.ServletUtil; @@ -44,10 +45,10 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) String q = request.getParameter("q"); // https://ace.jlab.org/srm/ajax/search-user - String USER_QUERY_URL = System.getenv("JAM_USER_QUERY_URL"); + String USER_QUERY_URL = SettingsService.cachedSettings.get("USER_QUERY_URL"); if (USER_QUERY_URL == null) { - throw new ServletException("JAM_USER_QUERY_URL not set"); + throw new ServletException("USER_QUERY_URL not set"); } ParamBuilder builder = new ParamBuilder(); diff --git a/src/main/webapp/WEB-INF/tags/verification-panel.tag b/src/main/webapp/WEB-INF/tags/verification-panel.tag index 9706abc7..d71185b4 100644 --- a/src/main/webapp/WEB-INF/tags/verification-panel.tag +++ b/src/main/webapp/WEB-INF/tags/verification-panel.tag @@ -92,7 +92,7 @@ - +