Adding ability for an EditConfiguration to specify a redirect instead of a form. NIHVIVO-3369

This commit is contained in:
briancaruso 2011-12-01 19:14:10 +00:00
parent 6f82977d9c
commit 59716efb7e
4 changed files with 35 additions and 19 deletions

View file

@ -9,8 +9,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues;
* context node. This is useful when you want to redirect to a URL
* created by the UrlBuilder which uses statics to sneak a context
* into the URL strings it creates.
*
* @author bdc34
*/
public class DirectRedirectResponseValues extends RedirectResponseValues {

View file

@ -13,11 +13,14 @@ public class RedirectResponseValues extends BaseResponseValues {
private final String redirectUrl;
//TODO: document this. What does this do and mean?
//should redirectUrl have the context? Or is the context added?
//If the context is added, what if we already have it because
//UrlBuilder was used?
//what about an off site redirect? Maybe check for a magic "://" ?
/**
* The string redirectUrl will get the context added.
If you want a redirect for a URL that has the context already added,
as is the case if a UrlBuilder was used. use the class DirectRedirectResponseValues.
This will attempt to handle an off site redirect by checking for
"://" in the URL.
*/
public RedirectResponseValues(String redirectUrl) {
this.redirectUrl = getRedirectUrl(redirectUrl);
}

View file

@ -127,6 +127,12 @@ public class EditConfigurationVTwo {
* to the original form. */
String formUrl;
/**
* skipToUrl is a URL that should be forwarded to instead of displaying
* a form. This will need the context if it is relative. It may be a
* full off site URL.
*/
String skipToUrl;
String editKey;
@ -1033,4 +1039,12 @@ public class EditConfigurationVTwo {
return this.urlToReturnTo;
}
public void setSkipToUrl(String url){
skipToUrl=url;
}
public String getSkipToUrl() {
return skipToUrl;
}
}

View file

@ -20,6 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.DirectRedirectResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
@ -64,23 +65,25 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
}
//if edit form needs to be skipped to object instead
if(isSkipEditForm(vreq)) {
if(isSkipPredicate(vreq)) {
return processSkipEditForm(vreq);
}
//Get the edit generator name
String editConfGeneratorName = processEditConfGeneratorName(vreq);
//forward to create new handled in default object property form generator
//session attribute
setSessionRequestFromEntity(vreq);
//Test
/**** make new or get an existing edit configuration ***/
// make new or get an existing edit configuration
EditConfigurationVTwo editConfig = setupEditConfiguration(editConfGeneratorName, vreq);
log.debug("editConfiguration:\n" + editConfig );
//if the EditConfig indicates a URL to skip to, then redirect to that URL
if( editConfig.getSkipToUrl() != null ){
return new DirectRedirectResponseValues(editConfig.getSkipToUrl());
}
//what template?
String template = editConfig.getTemplate();
@ -111,9 +114,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
}
}
private MultiValueEditSubmission getMultiValueSubmission(VitroRequest vreq, EditConfigurationVTwo editConfig) {
private MultiValueEditSubmission getMultiValueSubmission(VitroRequest vreq, EditConfigurationVTwo editConfig) {
return EditSubmissionUtils.getEditSubmissionFromSession(vreq.getSession(), editConfig);
}
@ -238,7 +239,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
//if skip edit form
private boolean isSkipEditForm(VitroRequest vreq) {
private boolean isSkipPredicate(VitroRequest vreq) {
//Certain predicates may be annotated to change the behavior of the edit
//link. Check for this annotation and, if present, simply redirect
//to the normal individual display for the object URI instead of bringing