← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8265: made /api/metaData use task-system for import jobs. two new entrypoints have been added, /api/sys...

 

------------------------------------------------------------
revno: 8265
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-09-26 15:46:31 +0700
message:
  made /api/metaData use task-system for import jobs. two new entrypoints have been added, /api/system/tasks/{ID} and /api/system/taskSummaries/{ID} for getting information during import. Calling taskSummaries will clear out all notification history for current task.
added:
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/tasks/
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/tasks/ImportMetaDataTask.java
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notification.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added directory 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/tasks'
=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/tasks/ImportMetaDataTask.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/tasks/ImportMetaDataTask.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/tasks/ImportMetaDataTask.java	2012-09-26 08:46:31 +0000
@@ -0,0 +1,70 @@
+package org.hisp.dhis.dxf2.metadata.tasks;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dxf2.metadata.ImportOptions;
+import org.hisp.dhis.dxf2.metadata.ImportService;
+import org.hisp.dhis.dxf2.metadata.MetaData;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.scheduling.TaskId;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class ImportMetaDataTask
+    implements Runnable
+{
+    private static final Log log = LogFactory.getLog( ImportMetaDataTask.class );
+
+    private ImportService importService;
+
+    private ImportOptions importOptions;
+
+    private TaskId taskId;
+
+    private MetaData metaData;
+
+    public ImportMetaDataTask( ImportService importService, ImportOptions importOptions, TaskId taskId, MetaData metaData )
+    {
+        this.importService = importService;
+        this.importOptions = importOptions;
+        this.taskId = taskId;
+        this.metaData = metaData;
+    }
+
+    @Override
+    public void run()
+    {
+        importService.importMetaData( metaData, importOptions, taskId );
+    }
+}

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notification.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notification.java	2012-04-12 12:39:47 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notification.java	2012-09-26 08:46:31 +0000
@@ -29,12 +29,20 @@
 
 import java.util.Date;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.CodeGenerator;
+import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.scheduling.TaskCategory;
 
 /**
  * @author Lars Helge Overland
  */
+@JacksonXmlRootElement( localName = "notification", namespace = Dxf2Namespace.NAMESPACE )
 public class Notification
 {
     private String uid;
@@ -72,11 +80,20 @@
     // Get and set
     // -------------------------------------------------------------------------
 
+    @JsonProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public NotificationLevel getLevel()
     {
         return level;
     }
 
+    public void setLevel( NotificationLevel level )
+    {
+        this.level = level;
+    }
+
+    @JsonProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getUid()
     {
         return uid;
@@ -87,11 +104,8 @@
         this.uid = uid;
     }
 
-    public void setLevel( NotificationLevel level )
-    {
-        this.level = level;
-    }
-
+    @JsonProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public TaskCategory getCategory()
     {
         return category;
@@ -102,6 +116,8 @@
         this.category = category;
     }
 
+    @JsonProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public Date getTime()
     {
         return time;
@@ -112,6 +128,8 @@
         this.time = time;
     }
 
+    @JsonProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getMessage()
     {
         return message;
@@ -122,6 +140,8 @@
         this.message = message;
     }
 
+    @JsonProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public boolean isCompleted()
     {
         return completed;

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java	2012-06-25 20:14:42 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java	2012-09-26 08:46:31 +0000
@@ -31,7 +31,12 @@
 import org.hisp.dhis.api.utils.ContextUtils.CacheStrategy;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dxf2.metadata.*;
+import org.hisp.dhis.dxf2.metadata.tasks.ImportMetaDataTask;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.scheduling.TaskCategory;
+import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.system.scheduling.Scheduler;
+import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -66,6 +71,12 @@
     @Autowired
     private ContextUtils contextUtils;
 
+    @Autowired
+    private Scheduler scheduler;
+
+    @Autowired
+    private CurrentUserService currentUserService;
+
     //--------------------------------------------------------------------------
     // Export
     //--------------------------------------------------------------------------
@@ -107,7 +118,7 @@
         JacksonUtils.toXmlWithView( response.getOutputStream(), metaData, ExportView.class );
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".zip" }, produces = "*/*" )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".zip"}, produces = "*/*" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
     public void exportZipped( @RequestParam Map<String, String> parameters, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
@@ -123,7 +134,7 @@
         }
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".xml.zip" }, produces = "*/*" )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".xml.zip"}, produces = "*/*" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
     public void exportZippedXML( @RequestParam Map<String, String> parameters, HttpServletResponse response ) throws IOException
     {
@@ -139,7 +150,7 @@
         JacksonUtils.toXmlWithView( zip, metaData, ExportView.class );
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".json.zip" }, produces = "*/*" )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".json.zip"}, produces = "*/*" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
     public void exportZippedJSON( @RequestParam Map<String, String> parameters, HttpServletResponse response ) throws IOException
     {
@@ -155,7 +166,7 @@
         JacksonUtils.toJsonWithView( zip, metaData, ExportView.class );
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".gz" }, produces = "*/*" )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".gz"}, produces = "*/*" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
     public void exportGZipped( @RequestParam Map<String, String> parameters, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
@@ -171,7 +182,7 @@
         }
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".xml.gz" }, produces = "*/*" )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".xml.gz"}, produces = "*/*" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
     public void exportGZippedXML( @RequestParam Map<String, String> parameters, HttpServletResponse response ) throws IOException
     {
@@ -185,7 +196,7 @@
         JacksonUtils.toXmlWithView( gzip, metaData, ExportView.class );
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".json.gz" }, produces = "*/*" )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".json.gz"}, produces = "*/*" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
     public void exportGZippedJSON( @RequestParam Map<String, String> parameters, HttpServletResponse response ) throws IOException
     {
@@ -203,16 +214,18 @@
     // Import
     //--------------------------------------------------------------------------
 
-    @RequestMapping( value = MetaDataController.RESOURCE_PATH, method = RequestMethod.POST, consumes = { "application/xml", "text/*" } )
+    @RequestMapping( value = MetaDataController.RESOURCE_PATH, method = RequestMethod.POST, consumes = {"application/xml", "text/*"} )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" )
     public void importXml( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws JAXBException, IOException
     {
         MetaData metaData = JacksonUtils.fromXml( request.getInputStream(), MetaData.class );
 
-        ImportSummary summary = importService.importMetaData( metaData, importOptions );
-
-        response.setContentType( MediaType.APPLICATION_XML.toString() );
-        JacksonUtils.toXml( response.getOutputStream(), summary );
+        TaskId taskId = new TaskId( TaskCategory.METADATA_IMPORT, currentUserService.getCurrentUser() );
+
+        scheduler.executeTask( new ImportMetaDataTask( importService, importOptions,taskId, metaData ) );
+
+        response.setHeader( "Location", ContextUtils.getRootPath( request ) + "/system/tasks/" + TaskCategory.METADATA_IMPORT );
+        response.setStatus( HttpServletResponse.SC_NO_CONTENT );
     }
 
     @RequestMapping( value = MetaDataController.RESOURCE_PATH, method = RequestMethod.POST, consumes = "application/json" )
@@ -221,13 +234,15 @@
     {
         MetaData metaData = JacksonUtils.fromJson( request.getInputStream(), MetaData.class );
 
-        ImportSummary summary = importService.importMetaData( metaData, importOptions );
-
-        response.setContentType( MediaType.APPLICATION_JSON.toString() );
-        JacksonUtils.toJson( response.getOutputStream(), summary );
+        TaskId taskId = new TaskId( TaskCategory.METADATA_IMPORT, currentUserService.getCurrentUser() );
+
+        scheduler.executeTask( new ImportMetaDataTask( importService, importOptions,taskId, metaData ) );
+
+        response.setHeader( "Location", ContextUtils.getRootPath( request ) + "/system/tasks/" + TaskCategory.METADATA_IMPORT );
+        response.setStatus( HttpServletResponse.SC_NO_CONTENT );
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".zip", MetaDataController.RESOURCE_PATH + ".xml.zip" }, method = RequestMethod.POST, consumes = { "application/xml", "text/*" } )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".zip", MetaDataController.RESOURCE_PATH + ".xml.zip"}, method = RequestMethod.POST, consumes = {"application/xml", "text/*"} )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" )
     public void importZippedXml( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws JAXBException, IOException
     {
@@ -236,13 +251,15 @@
 
         MetaData metaData = JacksonUtils.fromXml( zip, MetaData.class );
 
-        ImportSummary summary = importService.importMetaData( metaData, importOptions );
-
-        response.setContentType( MediaType.APPLICATION_XML.toString() );
-        JacksonUtils.toXml( response.getOutputStream(), summary );
+        TaskId taskId = new TaskId( TaskCategory.METADATA_IMPORT, currentUserService.getCurrentUser() );
+
+        scheduler.executeTask( new ImportMetaDataTask( importService, importOptions,taskId, metaData ) );
+
+        response.setHeader( "Location", ContextUtils.getRootPath( request ) + "/system/tasks/" + TaskCategory.METADATA_IMPORT );
+        response.setStatus( HttpServletResponse.SC_NO_CONTENT );
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".zip", MetaDataController.RESOURCE_PATH + ".json.zip" }, method = RequestMethod.POST, consumes = "application/json" )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".zip", MetaDataController.RESOURCE_PATH + ".json.zip"}, method = RequestMethod.POST, consumes = "application/json" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" )
     public void importZippedJson( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
@@ -251,37 +268,41 @@
 
         MetaData metaData = JacksonUtils.fromJson( zip, MetaData.class );
 
-        ImportSummary summary = importService.importMetaData( metaData, importOptions );
-
-        response.setContentType( MediaType.APPLICATION_JSON.toString() );
-        JacksonUtils.toJson( response.getOutputStream(), summary );
+        TaskId taskId = new TaskId( TaskCategory.METADATA_IMPORT, currentUserService.getCurrentUser() );
+
+        scheduler.executeTask( new ImportMetaDataTask( importService, importOptions,taskId, metaData ) );
+
+        response.setHeader( "Location", ContextUtils.getRootPath( request ) + "/system/tasks/" + TaskCategory.METADATA_IMPORT );
+        response.setStatus( HttpServletResponse.SC_NO_CONTENT );
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".gz", MetaDataController.RESOURCE_PATH + ".xml.gz" }, method = RequestMethod.POST, consumes = { "application/xml", "text/*" } )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".gz", MetaDataController.RESOURCE_PATH + ".xml.gz"}, method = RequestMethod.POST, consumes = {"application/xml", "text/*"} )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" )
     public void importGZippedXml( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws JAXBException, IOException
     {
         GZIPInputStream gzip = new GZIPInputStream( request.getInputStream() );
-
         MetaData metaData = JacksonUtils.fromXml( gzip, MetaData.class );
 
-        ImportSummary summary = importService.importMetaData( metaData, importOptions );
-
-        response.setContentType( MediaType.APPLICATION_XML.toString() );
-        JacksonUtils.toXml( response.getOutputStream(), summary );
+        TaskId taskId = new TaskId( TaskCategory.METADATA_IMPORT, currentUserService.getCurrentUser() );
+
+        scheduler.executeTask( new ImportMetaDataTask( importService, importOptions,taskId, metaData ) );
+
+        response.setHeader( "Location", ContextUtils.getRootPath( request ) + "/system/tasks/" + TaskCategory.METADATA_IMPORT );
+        response.setStatus( HttpServletResponse.SC_NO_CONTENT );
     }
 
-    @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".gz", MetaDataController.RESOURCE_PATH + ".json.gz" }, method = RequestMethod.POST, consumes = "application/json" )
+    @RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".gz", MetaDataController.RESOURCE_PATH + ".json.gz"}, method = RequestMethod.POST, consumes = "application/json" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" )
     public void importGZippedJson( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
         GZIPInputStream gzip = new GZIPInputStream( request.getInputStream() );
-
         MetaData metaData = JacksonUtils.fromJson( gzip, MetaData.class );
 
-        ImportSummary summary = importService.importMetaData( metaData, importOptions );
-
-        response.setContentType( MediaType.APPLICATION_JSON.toString() );
-        JacksonUtils.toJson( response.getOutputStream(), summary );
+        TaskId taskId = new TaskId( TaskCategory.METADATA_IMPORT, currentUserService.getCurrentUser() );
+
+        scheduler.executeTask( new ImportMetaDataTask( importService, importOptions,taskId, metaData ) );
+
+        response.setHeader( "Location", ContextUtils.getRootPath( request ) + "/system/tasks/" + TaskCategory.METADATA_IMPORT );
+        response.setStatus( HttpServletResponse.SC_NO_CONTENT );
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java	2012-05-31 17:02:03 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java	2012-09-26 08:46:31 +0000
@@ -28,12 +28,24 @@
  */
 
 import org.hisp.dhis.common.CodeGenerator;
+import org.hisp.dhis.dxf2.metadata.ImportSummary;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.scheduling.TaskCategory;
+import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.system.notification.Notification;
+import org.hisp.dhis.system.notification.Notifier;
+import org.hisp.dhis.system.scheduling.Scheduler;
+import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -44,6 +56,15 @@
 {
     public static final String RESOURCE_PATH = "/system";
 
+    @Autowired
+    private Scheduler scheduler;
+
+    @Autowired
+    private CurrentUserService currentUserService;
+
+    @Autowired
+    private Notifier notifier;
+
     //--------------------------------------------------------------------------
     // UID Generator
     //--------------------------------------------------------------------------
@@ -54,4 +75,40 @@
         response.setContentType( "text/plain" );
         response.getWriter().write( CodeGenerator.generateCode() );
     }
+
+    @RequestMapping( value = "/tasks/{category}", method = RequestMethod.GET, produces = {"*/*", "application/json"} )
+    public void getTaskJson( HttpServletResponse response, @PathVariable( "category" ) String category ) throws IOException
+    {
+        List<Notification> notifications = new ArrayList<Notification>();
+
+        if ( category != null )
+        {
+            TaskCategory taskCategory = TaskCategory.valueOf( category.toUpperCase() );
+
+            TaskId taskId = new TaskId( taskCategory, currentUserService.getCurrentUser() );
+
+            notifications = notifier.getNotifications( taskId, taskCategory, null );
+        }
+
+        JacksonUtils.toJson( response.getOutputStream(), notifications );
+    }
+
+    @RequestMapping( value = "/taskSummaries/{category}", method = RequestMethod.GET, produces = {"*/*", "application/json"} )
+    public void getTaskSummaryJson( HttpServletResponse response, @PathVariable( "category" ) String category ) throws IOException
+    {
+        ImportSummary importSummary = new ImportSummary();
+
+        if ( category != null )
+        {
+            TaskCategory taskCategory = TaskCategory.valueOf( category.toUpperCase() );
+
+            TaskId taskId = new TaskId( taskCategory, currentUserService.getCurrentUser() );
+
+            importSummary = (ImportSummary) notifier.getTaskSummary( taskId, taskCategory );
+
+            notifier.clear( taskId, taskCategory );
+        }
+
+        JacksonUtils.toJson( response.getOutputStream(), importSummary );
+    }
 }