Adding ability for an EditConfiguration to specify a redirect instead of a form. NIHVIVO-3369
This commit is contained in:
parent
6f82977d9c
commit
59716efb7e
4 changed files with 35 additions and 19 deletions
|
@ -8,9 +8,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues;
|
||||||
* It redirects to the URL specified. It does not attempt to add a
|
* It redirects to the URL specified. It does not attempt to add a
|
||||||
* context node. This is useful when you want to redirect to a URL
|
* context node. This is useful when you want to redirect to a URL
|
||||||
* created by the UrlBuilder which uses statics to sneak a context
|
* created by the UrlBuilder which uses statics to sneak a context
|
||||||
* into the URL strings it creates.
|
* into the URL strings it creates.
|
||||||
*
|
|
||||||
* @author bdc34
|
|
||||||
*/
|
*/
|
||||||
public class DirectRedirectResponseValues extends RedirectResponseValues {
|
public class DirectRedirectResponseValues extends RedirectResponseValues {
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,14 @@ public class RedirectResponseValues extends BaseResponseValues {
|
||||||
|
|
||||||
private final String redirectUrl;
|
private final String redirectUrl;
|
||||||
|
|
||||||
//TODO: document this. What does this do and mean?
|
/**
|
||||||
//should redirectUrl have the context? Or is the context added?
|
* The string redirectUrl will get the context added.
|
||||||
//If the context is added, what if we already have it because
|
If you want a redirect for a URL that has the context already added,
|
||||||
//UrlBuilder was used?
|
as is the case if a UrlBuilder was used. use the class DirectRedirectResponseValues.
|
||||||
//what about an off site redirect? Maybe check for a magic "://" ?
|
|
||||||
|
This will attempt to handle an off site redirect by checking for
|
||||||
|
"://" in the URL.
|
||||||
|
*/
|
||||||
public RedirectResponseValues(String redirectUrl) {
|
public RedirectResponseValues(String redirectUrl) {
|
||||||
this.redirectUrl = getRedirectUrl(redirectUrl);
|
this.redirectUrl = getRedirectUrl(redirectUrl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,12 @@ public class EditConfigurationVTwo {
|
||||||
* to the original form. */
|
* to the original form. */
|
||||||
String formUrl;
|
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;
|
String editKey;
|
||||||
|
|
||||||
|
@ -1032,5 +1038,13 @@ public class EditConfigurationVTwo {
|
||||||
public String getUrlToReturnTo() {
|
public String getUrlToReturnTo() {
|
||||||
return this.urlToReturnTo;
|
return this.urlToReturnTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSkipToUrl(String url){
|
||||||
|
skipToUrl=url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSkipToUrl() {
|
||||||
|
return skipToUrl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.beans.Property;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
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.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.RedirectResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
|
@ -64,22 +65,24 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
//if edit form needs to be skipped to object instead
|
//if edit form needs to be skipped to object instead
|
||||||
if(isSkipEditForm(vreq)) {
|
if(isSkipPredicate(vreq)) {
|
||||||
return processSkipEditForm(vreq);
|
return processSkipEditForm(vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the edit generator name
|
//Get the edit generator name
|
||||||
String editConfGeneratorName = processEditConfGeneratorName(vreq);
|
String editConfGeneratorName = processEditConfGeneratorName(vreq);
|
||||||
|
|
||||||
//forward to create new handled in default object property form generator
|
|
||||||
|
|
||||||
//session attribute
|
//session attribute
|
||||||
setSessionRequestFromEntity(vreq);
|
setSessionRequestFromEntity(vreq);
|
||||||
//Test
|
|
||||||
|
|
||||||
/**** make new or get an existing edit configuration ***/
|
// make new or get an existing edit configuration
|
||||||
EditConfigurationVTwo editConfig = setupEditConfiguration(editConfGeneratorName, vreq);
|
EditConfigurationVTwo editConfig = setupEditConfiguration(editConfGeneratorName, vreq);
|
||||||
log.debug("editConfiguration:\n" + editConfig );
|
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?
|
//what template?
|
||||||
String template = editConfig.getTemplate();
|
String template = editConfig.getTemplate();
|
||||||
|
@ -109,11 +112,9 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
||||||
return new TemplateResponseValues("error-message.ftl", map);
|
return new TemplateResponseValues("error-message.ftl", map);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private MultiValueEditSubmission getMultiValueSubmission(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
||||||
private MultiValueEditSubmission getMultiValueSubmission(VitroRequest vreq, EditConfigurationVTwo editConfig) {
|
|
||||||
return EditSubmissionUtils.getEditSubmissionFromSession(vreq.getSession(), editConfig);
|
return EditSubmissionUtils.getEditSubmissionFromSession(vreq.getSession(), editConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +239,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
|
|
||||||
//if skip edit form
|
//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
|
//Certain predicates may be annotated to change the behavior of the edit
|
||||||
//link. Check for this annotation and, if present, simply redirect
|
//link. Check for this annotation and, if present, simply redirect
|
||||||
//to the normal individual display for the object URI instead of bringing
|
//to the normal individual display for the object URI instead of bringing
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue