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,8 +571,10 @@ 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 = [];
for each (var qualifiedPath in styles) {

View File

@ -153,21 +153,32 @@ 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) {
theProject.metadata = data;
},
"/command/core/get-models?" + $.param({ project: theProject.id }), null,
function(data) {
for (var n in data) {
if (data.hasOwnProperty(n)) {
theProject[n] = data[n];
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) {
if (data.hasOwnProperty(n)) {
theProject[n] = data[n];
}
}
f();
},
'json'
);
}
},
f
'json'
);
};
@ -442,9 +453,14 @@ function onLoad() {
}
}
Refine.reinitializeProjectData(function() {
initializeUI(uiState);
});
Refine.reinitializeProjectData(
function() {
initializeUI(uiState);
},
function() {
$("#loading-message").hide();
}
);
}
}