Make sure project ID is completely numeric. Slightly better error reporting on project page when project ID is not valid.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2441 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2012-01-29 21:16:13 +00:00
parent 4fbfd17ddf
commit e21ae32722
3 changed files with 41 additions and 17 deletions

View File

@ -50,9 +50,15 @@ public class GetProjectMetadataCommand extends Command {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Project project = getProject(request);
try {
Project project;
try {
project = getProject(request);
} catch (ServletException e) {
respond(response, "error", e.getLocalizedMessage());
return;
}
respondJSON(response, ProjectManager.singleton.getProjectMetadata(project.id));
} catch (JSONException e) {
respondException(response, e);

View File

@ -571,7 +571,9 @@ function process(path, request, response) {
params.put(name, request.getParameterValues(name)[0]);
}
context.params = params;
context.projectID = request.getParameter("project");
// We prepend '' to convert the Java string to a Javascript string.
context.projectID = ('' + request.getParameter("project")).replace(/\D/g, '');
var styles = ClientSideResourceManager.getPaths(lastSegment + "/styles");
var styleInjection = [];

View File

@ -153,12 +153,18 @@ Refine.setTitle = function(status) {
$("#project-name-button").text(theProject.metadata.name);
};
Refine.reinitializeProjectData = function(f) {
Ajax.chainGetJSON(
Refine.reinitializeProjectData = function(f, fError) {
$.getJSON(
"/command/core/get-project-metadata?" + $.param({ project: theProject.id }), null,
function(data) {
if (data.status == 'error') {
alert(data.message);
if (fError) {
fError();
}
} else {
theProject.metadata = data;
},
$.getJSON(
"/command/core/get-models?" + $.param({ project: theProject.id }), null,
function(data) {
for (var n in data) {
@ -166,8 +172,13 @@ Refine.reinitializeProjectData = function(f) {
theProject[n] = data[n];
}
}
f();
},
f
'json'
);
}
},
'json'
);
};
@ -442,9 +453,14 @@ function onLoad() {
}
}
Refine.reinitializeProjectData(function() {
Refine.reinitializeProjectData(
function() {
initializeUI(uiState);
});
},
function() {
$("#loading-message").hide();
}
);
}
}