Fix Apache Proxy configuration property.
This commit is contained in:
@@ -18,29 +18,51 @@
|
||||
|
||||
package com.wisemapping.filter;
|
||||
|
||||
import com.wisemapping.exceptions.GoogleChromeFrameRequiredException;
|
||||
import com.wisemapping.exceptions.UnsupportedBrowserException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
|
||||
private Map<String, String> attributes;
|
||||
@Value("${google.analytics.enabled}")
|
||||
private Boolean analyticsEnabled;
|
||||
|
||||
@Value("${google.analytics.account}")
|
||||
private String analyticsAccount;
|
||||
|
||||
@Value("${google.ads.enabled}")
|
||||
private Boolean adsEnabled;
|
||||
|
||||
@Value("${site.homepage}")
|
||||
private String siteHomepage;
|
||||
|
||||
@Autowired
|
||||
Environment env;
|
||||
|
||||
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception {
|
||||
for (String key : attributes.keySet()) {
|
||||
request.setAttribute(key, attributes.get(key));
|
||||
|
||||
request.setAttribute("google.analytics.enabled", analyticsEnabled);
|
||||
request.setAttribute("google.analytics.account", analyticsAccount);
|
||||
request.setAttribute("google.ads.enabled", adsEnabled);
|
||||
request.setAttribute("site.homepage", siteHomepage);
|
||||
|
||||
final String baseUrl;
|
||||
if (env.containsProperty("site.baseurl")) {
|
||||
baseUrl = env.getProperty("site.baseurl");
|
||||
} else {
|
||||
baseUrl = request.getRequestURL().toString().replace(request.getRequestURI(), request.getContextPath());
|
||||
}
|
||||
request.setAttribute("site.baseurl", baseUrl);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.PrintWriter;
|
||||
@@ -37,12 +38,14 @@ import java.util.Map;
|
||||
|
||||
final public class NotificationService {
|
||||
|
||||
|
||||
public static final String DEFAULT_WISE_URL = "http://localhost:8080/wisemapping";
|
||||
@Autowired
|
||||
private Mailer mailer;
|
||||
private String baseUrl;
|
||||
|
||||
private NotifierFilter notificationFilter;
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
public NotificationService() {
|
||||
this.notificationFilter = new NotifierFilter();
|
||||
}
|
||||
@@ -64,8 +67,8 @@ final public class NotificationService {
|
||||
model.put("mindmap", mindmap);
|
||||
model.put("message", "message");
|
||||
model.put("ownerName", user.getFirstname());
|
||||
model.put("mapEditUrl", baseUrl + "/c/maps/" + mindmap.getId() + "/edit");
|
||||
model.put("baseUrl", baseUrl);
|
||||
model.put("mapEditUrl", getBaseUrl() + "/c/maps/" + mindmap.getId() + "/edit");
|
||||
model.put("baseUrl", getBaseUrl());
|
||||
model.put("senderMail", user.getEmail());
|
||||
model.put("message", message);
|
||||
model.put("supportEmail", mailer.getSupportEmail());
|
||||
@@ -83,7 +86,7 @@ final public class NotificationService {
|
||||
final String messageBody =
|
||||
"<p>Someone, most likely you, requested a new password for your WiseMapping account. </p>\n" +
|
||||
"<p><strong>Here is your new password: " + temporalPassword + "</strong></p>\n" +
|
||||
"<p>You can login clicking <a href=\"" + this.baseUrl + "/c/login\">here</a>. We strongly encourage you to change the password as soon as possible.</p>";
|
||||
"<p>You can login clicking <a href=\"" + getBaseUrl() + "/c/login\">here</a>. We strongly encourage you to change the password as soon as possible.</p>";
|
||||
|
||||
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
|
||||
}
|
||||
@@ -112,7 +115,7 @@ final public class NotificationService {
|
||||
model.put("firstName", user.getFirstname());
|
||||
model.put("messageTitle", messageTitle);
|
||||
model.put("messageBody", messageBody);
|
||||
model.put("baseUrl", this.baseUrl);
|
||||
model.put("baseUrl", getBaseUrl());
|
||||
model.put("supportEmail", mailer.getSupportEmail());
|
||||
|
||||
mailer.sendEmail(mailer.getServerSenderEmail(), user.getEmail(), mailSubject, model, "baseLayout.vm");
|
||||
@@ -127,10 +130,6 @@ final public class NotificationService {
|
||||
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public void setMailer(Mailer mailer) {
|
||||
this.mailer = mailer;
|
||||
}
|
||||
@@ -227,6 +226,17 @@ final public class NotificationService {
|
||||
return retValue;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
if ("${site.baseurl}".equals(baseUrl)) {
|
||||
baseUrl = DEFAULT_WISE_URL;
|
||||
System.err.println("Warning: site.baseurl has not being configured. Mail site references could be not properly sent. Using :" + baseUrl);
|
||||
}
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user