diff --git a/main/src/com/google/refine/commands/project/GetProjectMetadataCommand.java b/main/src/com/google/refine/commands/project/GetProjectMetadataCommand.java index 3442c8066..9e7337f87 100644 --- a/main/src/com/google/refine/commands/project/GetProjectMetadataCommand.java +++ b/main/src/com/google/refine/commands/project/GetProjectMetadataCommand.java @@ -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); diff --git a/main/webapp/modules/core/MOD-INF/controller.js b/main/webapp/modules/core/MOD-INF/controller.js index 95efb0d5a..676b68ac6 100644 --- a/main/webapp/modules/core/MOD-INF/controller.js +++ b/main/webapp/modules/core/MOD-INF/controller.js @@ -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) { diff --git a/main/webapp/modules/core/scripts/project.js b/main/webapp/modules/core/scripts/project.js index ff128c812..e6e8bdb06 100644 --- a/main/webapp/modules/core/scripts/project.js +++ b/main/webapp/modules/core/scripts/project.js @@ -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(); + } + ); } }