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) {
|
||||
|
||||
UtilityFunctions.handleMalformedParameters("Visualization Query Error",
|
||||
e.getMessage(),
|
||||
vreq,
|
||||
request,
|
||||
UtilityFunctions.handleMalformedParameters(e.getMessage(),
|
||||
response,
|
||||
log);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -93,10 +89,7 @@ public class DataVisualizationController extends VitroHttpServlet {
|
|||
} else {
|
||||
|
||||
UtilityFunctions.handleMalformedParameters(
|
||||
"Visualization Query Error",
|
||||
"Inappropriate query parameters were submitted.",
|
||||
vreq,
|
||||
request,
|
||||
response,
|
||||
log);
|
||||
|
||||
|
|
|
@ -140,8 +140,6 @@ public class EntityComparisonUtilityFunctions {
|
|||
Dataset dataset, VitroRequest vitroRequest)
|
||||
throws MalformedQueryParametersException {
|
||||
|
||||
String finalHighestLevelOrganizationURI = "";
|
||||
|
||||
String staffProvidedHighestLevelOrganization = ConfigurationProperties.getBean(vitroRequest)
|
||||
.getProperty("visualization.topLevelOrg");
|
||||
|
||||
|
@ -157,13 +155,15 @@ public class EntityComparisonUtilityFunctions {
|
|||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||
IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
|
||||
|
||||
if (iri.hasViolation(false)) {
|
||||
finalHighestLevelOrganizationURI = EntityComparisonUtilityFunctions
|
||||
.getHighestLevelOrganizationURI(log, dataset);
|
||||
} else {
|
||||
finalHighestLevelOrganizationURI = staffProvidedHighestLevelOrganization;
|
||||
|
||||
if (!iri.hasViolation(false)) {
|
||||
return 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,
|
||||
dataset,
|
||||
vitroRequest);
|
||||
|
||||
}
|
||||
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.TreeMap;
|
|||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
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.format.DateTimeFormatter;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
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.responsevalues.ResponseValues;
|
||||
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.visualization.constants.VOConstants;
|
||||
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.valueobjects.Activity;
|
||||
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;
|
||||
|
||||
public class UtilityFunctions {
|
||||
|
@ -142,30 +145,18 @@ public class UtilityFunctions {
|
|||
return new TemplateResponseValues(VisualizationFrameworkConstants.ERROR_TEMPLATE, body);
|
||||
}
|
||||
|
||||
public static void handleMalformedParameters(String errorPageTitle,
|
||||
String errorMessage,
|
||||
VitroRequest vitroRequest,
|
||||
HttpServletRequest request,
|
||||
public static void handleMalformedParameters(String errorMessage,
|
||||
HttpServletResponse response,
|
||||
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);
|
||||
request.setAttribute("bodyJsp", "/templates/visualization/visualization_error.jsp");
|
||||
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());
|
||||
}
|
||||
response.setContentType("application/octet-stream");
|
||||
response.getWriter().write(jsonErrorResponse.toJson(errorDataResponse));
|
||||
}
|
||||
|
||||
public static DateTime getValidParsedDateTimeObject(String unparsedDateTime) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue