2010-01-29 22:13:57 +00:00
|
|
|
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
|
|
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
|
2010-06-17 14:26:59 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.StringUtils" %>
|
2010-01-29 22:13:57 +00:00
|
|
|
<%@page import="org.apache.commons.logging.Log"%>
|
|
|
|
<%@page import="org.apache.commons.logging.LogFactory"%>
|
2010-04-09 18:17:52 +00:00
|
|
|
<%@page import="com.hp.hpl.jena.rdf.model.ResourceFactory"%>
|
|
|
|
<%@page import="com.hp.hpl.jena.rdf.model.Property"%>
|
2010-01-29 22:13:57 +00:00
|
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
|
|
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jstl/functions" %>
|
|
|
|
<%@ taglib uri="http://jakarta.apache.org/taglibs/string-1.1" prefix="str" %>
|
|
|
|
|
|
|
|
|
|
|
|
<%
|
|
|
|
/* Clear any cruft from session. */
|
2010-04-09 18:17:52 +00:00
|
|
|
String resourceToRedirectTo = null;
|
2010-01-29 22:13:57 +00:00
|
|
|
String urlPattern = null;
|
2010-04-09 18:17:52 +00:00
|
|
|
String predicateLocalName = null;
|
|
|
|
String predicateAnchor = "";
|
2010-01-29 22:13:57 +00:00
|
|
|
if( session != null ) {
|
|
|
|
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
|
|
|
//In order to support back button resubmissions, don't remove the editConfig from session.
|
|
|
|
//EditConfiguration.clearEditConfigurationInSession(session, editConfig);
|
|
|
|
|
|
|
|
EditSubmission editSub = EditSubmission.getEditSubmissionFromSession(session,editConfig);
|
|
|
|
EditSubmission.clearEditSubmissionInSession(session, editSub);
|
2010-04-09 18:17:52 +00:00
|
|
|
|
|
|
|
if( editConfig != null ){
|
|
|
|
String predicateUri = editConfig.getPredicateUri();
|
|
|
|
if( predicateUri != null ){
|
|
|
|
Property prop = ResourceFactory.createProperty(predicateUri);
|
|
|
|
predicateLocalName = prop.getLocalName();
|
|
|
|
}
|
2010-01-29 22:13:57 +00:00
|
|
|
|
2010-07-12 15:18:16 +00:00
|
|
|
if( editConfig.getEntityToReturnTo() != null && editConfig.getEntityToReturnTo().startsWith("?") ){
|
|
|
|
resourceToRedirectTo = (String)request.getAttribute("entityToReturnTo");
|
2010-01-29 22:13:57 +00:00
|
|
|
}else{
|
2010-04-09 18:17:52 +00:00
|
|
|
resourceToRedirectTo = editConfig.getEntityToReturnTo();
|
2010-07-12 15:18:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//if there is no entity to return to it is likely a cancel
|
|
|
|
if( resourceToRedirectTo == null || resourceToRedirectTo.length() == 0 )
|
|
|
|
resourceToRedirectTo = editConfig.getSubjectUri();
|
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
}
|
2010-04-09 18:17:52 +00:00
|
|
|
|
|
|
|
//set up base URL
|
2010-06-17 14:26:59 +00:00
|
|
|
String cancel = request.getParameter("cancel");
|
|
|
|
String urlPatternToReturnTo = null;
|
|
|
|
String urlPatternToCancelTo = null;
|
|
|
|
if (editConfig != null) {
|
|
|
|
urlPatternToReturnTo = editConfig.getUrlPatternToReturnTo();
|
|
|
|
urlPatternToCancelTo = request.getParameter("url");
|
|
|
|
}
|
|
|
|
// If a different cancel return path has been designated, use it. Otherwise, use the regular return path.
|
|
|
|
if (cancel != null && cancel.equals("true") && !StringUtils.isEmpty(urlPatternToCancelTo)) {
|
|
|
|
urlPattern = urlPatternToCancelTo;
|
|
|
|
}
|
|
|
|
else if (!StringUtils.isEmpty(urlPatternToReturnTo)) {
|
|
|
|
urlPattern = urlPatternToReturnTo;
|
|
|
|
} else {
|
|
|
|
urlPattern = "/individual";
|
2010-04-09 18:17:52 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 14:26:59 +00:00
|
|
|
//looks like a redirect to a profile page, try to add anchor for property that was just edited.
|
2010-04-09 18:17:52 +00:00
|
|
|
if( urlPattern.endsWith("individual") || urlPattern.endsWith("entity") ){
|
|
|
|
if( predicateLocalName != null && predicateLocalName.length() > 0){
|
|
|
|
predicateAnchor = "#" + predicateLocalName;
|
|
|
|
request.setAttribute("predicateAnchor", predicateAnchor);
|
|
|
|
}
|
2010-01-29 22:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-09 18:17:52 +00:00
|
|
|
|
2010-07-04 19:43:36 +00:00
|
|
|
if( resourceToRedirectTo != null ){ %>
|
|
|
|
<c:url context="/" var="encodedUrl" value="<%=urlPattern%>">
|
|
|
|
<c:param name="uri" value="<%=resourceToRedirectTo%>" />
|
|
|
|
<c:param name="extra" value="true"/> <%-- For ie6 --%>
|
|
|
|
</c:url>
|
|
|
|
<c:redirect url="${encodedUrl}${predicateAnchor}" />
|
2010-01-29 22:13:57 +00:00
|
|
|
<% } else { %>
|
|
|
|
<c:redirect url="<%= Controllers.LOGIN %>" />
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<%!
|
|
|
|
Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.edit.postEditCleanUp.jsp");
|
|
|
|
%>
|
|
|
|
|
|
|
|
|
|
|
|
|