1515 */
1616package org .labkey .api .ldk .notification ;
1717
18- import org .apache .logging .log4j .LogManager ;
1918import org .apache .logging .log4j .Logger ;
2019import org .jetbrains .annotations .Nullable ;
2120import org .labkey .api .data .Container ;
2221import org .labkey .api .data .SimpleFilter ;
2322import org .labkey .api .module .Module ;
24- import org .labkey .api .query .DetailsURL ;
25- import org .labkey .api .settings .AppProps ;
23+ import org .labkey .api .query .QueryUrls ;
2624import org .labkey .api .settings .LookAndFeelProperties ;
25+ import org .labkey .api .util .PageFlowUtil ;
26+ import org .labkey .api .util .logging .LogHelper ;
27+ import org .labkey .api .view .ActionURL ;
2728
2829import java .text .DateFormat ;
2930import java .text .SimpleDateFormat ;
3536 */
3637abstract public class AbstractNotification implements Notification
3738{
38- private Module _owner ;
39+ private final Module _owner ;
3940
40- protected final static Logger log = LogManager .getLogger (AbstractNotification .class );
41+ protected final static Logger log = LogHelper .getLogger (AbstractNotification .class , "LDK notification errors" );
4142 protected final static SimpleDateFormat _timeFormat = new SimpleDateFormat ("kk:mm" );
43+ protected final static QueryUrls _queryUrls = PageFlowUtil .urlProvider (QueryUrls .class );
4244
4345 public AbstractNotification (Module owner )
4446 {
4547 _owner = owner ;
48+
49+ // AbstractNotifications must be constructed after QueryUrls has been registered, typically in startup() or
50+ // doStartupAfterSpringConfig()
51+ assert _queryUrls != null ;
4652 }
4753
4854 @ Override
@@ -57,21 +63,21 @@ protected String getExecuteQueryUrl(Container c, String schemaName, String query
5763 }
5864
5965 /**
60- * This should really be using URLHelpers better, but there is a lot of legacy URL strings
61- * migrated into java and its not worth changing all of it at this point
66+ * Returned URL always contains a couple parameters and therefore always has a "?". It should return an ActionURL,
67+ * but there is a lot of legacy URL string manipulation migrated into java, and it's not worth changing all of it
68+ * at this point.
6269 */
6370 protected String getExecuteQueryUrl (Container c , String schemaName , String queryName , @ Nullable String viewName , @ Nullable SimpleFilter filter )
6471 {
65- DetailsURL url = DetailsURL .fromString ("/query/executeQuery.view" , c );
66- String ret = AppProps .getInstance ().getBaseServerUrl () + url .getActionURL ().toString ();
67- ret += "schemaName=" + schemaName + "&query.queryName=" + queryName ;
72+ ActionURL url = _queryUrls .urlExecuteQuery (c , schemaName , queryName );
73+
6874 if (viewName != null )
69- ret += "& query.viewName=" + viewName ;
75+ url . addParameter ( " query.viewName" , viewName ) ;
7076
71- if (filter != null )
72- ret += "&" + filter .toQueryString ( "query" );
77+ if (filter != null )
78+ filter .applyToURL ( url , "query" );
7379
74- return ret ;
80+ return url . getURIString (); // Return an absolute URL since links are sent via email
7581 }
7682
7783 public DateFormat getDateFormat (Container c )
0 commit comments