diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/responsevalues/DirectRedirectResponseValues.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/responsevalues/DirectRedirectResponseValues.java index 219b9ed37..1123c6b44 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/responsevalues/DirectRedirectResponseValues.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/responsevalues/DirectRedirectResponseValues.java @@ -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 * 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 + * into the URL strings it creates. */ public class DirectRedirectResponseValues extends RedirectResponseValues { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/responsevalues/RedirectResponseValues.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/responsevalues/RedirectResponseValues.java index 4ab68e5b0..3e852be92 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/responsevalues/RedirectResponseValues.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/responsevalues/RedirectResponseValues.java @@ -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); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/EditConfigurationVTwo.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/EditConfigurationVTwo.java index a79abf141..61e11a63e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/EditConfigurationVTwo.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/EditConfigurationVTwo.java @@ -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; @@ -1032,5 +1038,13 @@ public class EditConfigurationVTwo { public String getUrlToReturnTo() { return this.urlToReturnTo; } + + public void setSkipToUrl(String url){ + skipToUrl=url; + } + + public String getSkipToUrl() { + return skipToUrl; + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java index 47ce89cb9..98a44efe9 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/controller/EditRequestDispatchController.java @@ -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,22 +65,24 @@ 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(); @@ -109,11 +112,9 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet { 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); } @@ -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