1. Fix for incorrect error response in case of DataVisualization request. see http://issues.library.cornell.edu/browse/NIHVIVO-2200
2. Also fix for incorrect logic flow in resolving the highest level org.
This commit is contained in:
parent
d00685eee0
commit
e14b399147
4 changed files with 279 additions and 294 deletions
|
@ -79,13 +79,9 @@ public class DataVisualizationController extends VitroHttpServlet {
|
||||||
|
|
||||||
} catch (MalformedQueryParametersException e) {
|
} catch (MalformedQueryParametersException e) {
|
||||||
|
|
||||||
UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
UtilityFunctions.handleMalformedParameters(e.getMessage(),
|
||||||
e.getMessage(),
|
|
||||||
vreq,
|
|
||||||
request,
|
|
||||||
response,
|
response,
|
||||||
log);
|
log);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -93,10 +89,7 @@ public class DataVisualizationController extends VitroHttpServlet {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
UtilityFunctions.handleMalformedParameters(
|
UtilityFunctions.handleMalformedParameters(
|
||||||
"Visualization Query Error",
|
|
||||||
"Inappropriate query parameters were submitted.",
|
"Inappropriate query parameters were submitted.",
|
||||||
vreq,
|
|
||||||
request,
|
|
||||||
response,
|
response,
|
||||||
log);
|
log);
|
||||||
|
|
||||||
|
|
|
@ -140,8 +140,6 @@ public class EntityComparisonUtilityFunctions {
|
||||||
Dataset dataset, VitroRequest vitroRequest)
|
Dataset dataset, VitroRequest vitroRequest)
|
||||||
throws MalformedQueryParametersException {
|
throws MalformedQueryParametersException {
|
||||||
|
|
||||||
String finalHighestLevelOrganizationURI = "";
|
|
||||||
|
|
||||||
String staffProvidedHighestLevelOrganization = ConfigurationProperties.getBean(vitroRequest)
|
String staffProvidedHighestLevelOrganization = ConfigurationProperties.getBean(vitroRequest)
|
||||||
.getProperty("visualization.topLevelOrg");
|
.getProperty("visualization.topLevelOrg");
|
||||||
|
|
||||||
|
@ -157,13 +155,15 @@ public class EntityComparisonUtilityFunctions {
|
||||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||||
IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
|
IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
|
||||||
|
|
||||||
if (iri.hasViolation(false)) {
|
|
||||||
finalHighestLevelOrganizationURI = EntityComparisonUtilityFunctions
|
if (!iri.hasViolation(false)) {
|
||||||
.getHighestLevelOrganizationURI(log, dataset);
|
return staffProvidedHighestLevelOrganization;
|
||||||
} else {
|
|
||||||
finalHighestLevelOrganizationURI = staffProvidedHighestLevelOrganization;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return finalHighestLevelOrganizationURI;
|
|
||||||
|
/*
|
||||||
|
* If the provided value was not proper compute it yourself.
|
||||||
|
* */
|
||||||
|
return EntityComparisonUtilityFunctions.getHighestLevelOrganizationURI(log, dataset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class EntityPublicationCountRequestHandler implements
|
||||||
log,
|
log,
|
||||||
dataset,
|
dataset,
|
||||||
vitroRequest);
|
vitroRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
|
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.util.TreeMap;
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -19,6 +18,8 @@ import org.apache.commons.logging.Log;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -26,12 +27,14 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
||||||
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;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.DataVisualizationController;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
|
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.collaborationutils.CollaborationData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.collaborationutils.CollaborationData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Activity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Activity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Collaborator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Collaborator;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.GenericQueryMap;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
|
||||||
|
|
||||||
public class UtilityFunctions {
|
public class UtilityFunctions {
|
||||||
|
@ -142,30 +145,18 @@ public class UtilityFunctions {
|
||||||
return new TemplateResponseValues(VisualizationFrameworkConstants.ERROR_TEMPLATE, body);
|
return new TemplateResponseValues(VisualizationFrameworkConstants.ERROR_TEMPLATE, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleMalformedParameters(String errorPageTitle,
|
public static void handleMalformedParameters(String errorMessage,
|
||||||
String errorMessage,
|
HttpServletResponse response,
|
||||||
VitroRequest vitroRequest,
|
|
||||||
HttpServletRequest request,
|
|
||||||
HttpServletResponse response,
|
|
||||||
Log log)
|
Log log)
|
||||||
throws ServletException, IOException {
|
throws IOException {
|
||||||
|
|
||||||
Portal portal = vitroRequest.getPortal();
|
GenericQueryMap errorDataResponse = new GenericQueryMap();
|
||||||
|
errorDataResponse.addEntry("error", errorMessage);
|
||||||
|
|
||||||
request.setAttribute("error", errorMessage);
|
Gson jsonErrorResponse = new Gson();
|
||||||
|
|
||||||
RequestDispatcher requestDispatcher = request.getRequestDispatcher(Controllers.BASIC_JSP);
|
response.setContentType("application/octet-stream");
|
||||||
request.setAttribute("bodyJsp", "/templates/visualization/visualization_error.jsp");
|
response.getWriter().write(jsonErrorResponse.toJson(errorDataResponse));
|
||||||
request.setAttribute("portalBean", portal);
|
|
||||||
request.setAttribute("title", errorPageTitle);
|
|
||||||
|
|
||||||
try {
|
|
||||||
requestDispatcher.forward(request, response);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("EntityEditController could not forward to view.");
|
|
||||||
log.error(e.getMessage());
|
|
||||||
log.error(e.getStackTrace());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DateTime getValidParsedDateTimeObject(String unparsedDateTime) {
|
public static DateTime getValidParsedDateTimeObject(String unparsedDateTime) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue