Modify RedirectResponseValues constructor so the redirectUrl does not contain the context path, but gets added by the constructor. Create file for v1.3 upgrade notes.

This commit is contained in:
ryounes 2011-03-31 21:04:27 +00:00
parent 54de8d5f5b
commit 3f32805b68
6 changed files with 24 additions and 14 deletions

View file

@ -91,8 +91,7 @@ public class FakeExternalAuthController extends FreemarkerHttpServlet {
}
private RedirectResponseValues makeRedirectResponse() {
return new RedirectResponseValues(
UrlBuilder.getUrl(URL_EXTERNAL_AUTH_RETURN));
return new RedirectResponseValues(URL_EXTERNAL_AUTH_RETURN);
}
/**

View file

@ -163,8 +163,7 @@ public class ImageUploadController extends FreemarkerHttpServlet {
// If they aren't authorized to do this, send them to login.
if (!checkAuthorized(vreq)) {
String loginPage = request.getContextPath() + Controllers.LOGIN;
return new RedirectResponseValues(loginPage);
return new RedirectResponseValues(Controllers.LOGIN);
}
return buildTheResponse(vreq);
@ -464,7 +463,7 @@ public class ImageUploadController extends FreemarkerHttpServlet {
/**
* When we complete the process, by success or by cancellation, go to the
* initial referring page. If there wasn't one, go to the individual display
* page,
* page.
*/
private String exitPageUrl(VitroRequest vreq, String entityUri) {
String referrer = (String) vreq.getSession().getAttribute(

View file

@ -94,7 +94,7 @@ public class IndividualController extends FreemarkerHttpServlet {
// Check to see if the request is for a non-information resource, redirect if it is.
String redirectURL = checkForRedirect ( url, vreq );
if( redirectURL != null ){
return new RedirectResponseValues(UrlBuilder.getUrl(redirectURL));
return new RedirectResponseValues(redirectURL);
}
Individual individual = null;
@ -116,7 +116,7 @@ public class IndividualController extends FreemarkerHttpServlet {
// If this is an uploaded file, redirect to its "alias URL".
String aliasUrl = getAliasUrlForBytestreamIndividual(vreq, individual);
if (aliasUrl != null) {
return new RedirectResponseValues(UrlBuilder.getUrl(aliasUrl));
return new RedirectResponseValues(aliasUrl);
}
Map<String, Object> body = new HashMap<String, Object>();
@ -715,9 +715,9 @@ public class IndividualController extends FreemarkerHttpServlet {
queryStr = "?" + queryStr;
StringBuilder url = new StringBuilder();
url.append( vreq.getContextPath() );
if( vreq.getContextPath() != null && !vreq.getContextPath().endsWith("/"))
url.append('/');
// url.append( vreq.getContextPath() );
// if( vreq.getContextPath() != null && !vreq.getContextPath().endsWith("/"))
// url.append('/');
if( portalPrefix != null && !"".equals(portalPrefix))
url.append( portalPrefix ).append('/');

View file

@ -38,7 +38,7 @@ public class SDBSetupController extends FreemarkerHttpServlet {
// Due to requiresLoginLevel(), we don't get here unless logged in as DBA
if (!LoginStatusBean.getBean(vreq)
.isLoggedInAtLeast(LoginStatusBean.DBA)) {
return new RedirectResponseValues(UrlBuilder.getUrl(Route.LOGIN));
return new RedirectResponseValues(Route.LOGIN);
}
Map<String, Object> body = new HashMap<String, Object>();

View file

@ -30,7 +30,7 @@ public class SimpleReasonerRecomputeController extends FreemarkerHttpServlet {
// Due to requiresLoginLevel(), we don't get here unless logged in as DBA
if (!LoginStatusBean.getBean(vreq)
.isLoggedInAtLeast(LoginStatusBean.DBA)) {
return new RedirectResponseValues(UrlBuilder.getUrl(Route.LOGIN));
return new RedirectResponseValues(Route.LOGIN);
}
Map<String, Object> body = new HashMap<String, Object>();

View file

@ -2,22 +2,34 @@
package edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
public class RedirectResponseValues extends BaseResponseValues {
private final String redirectUrl;
public RedirectResponseValues(String redirectUrl) {
this.redirectUrl = redirectUrl;
this.redirectUrl = getRedirectUrl(redirectUrl);
}
public RedirectResponseValues(String redirectUrl, int statusCode) {
super(statusCode);
this.redirectUrl = redirectUrl;
this.redirectUrl = getRedirectUrl(redirectUrl);
}
public RedirectResponseValues(Route redirectUrl) {
this.redirectUrl = UrlBuilder.getUrl(redirectUrl);
}
@Override
public String getRedirectUrl() {
return this.redirectUrl;
}
private String getRedirectUrl(String redirectUrl) {
return redirectUrl.contains("://") ? redirectUrl : UrlBuilder.getUrl(redirectUrl);
}
}